Basically we need this for https://github.com/gsquire/sendgrid-rs/pull/69, https://github.com/gsquire/sendgrid-rs/issues/66
We were doing resp.text() there, but I don't think it's good enough, reqwest should offer a way to get response body while error happens. Maybe have a way to enrich resp.error_for_status_code
Any idea on this?
Could you say more what the problem is? I don't understand what exactly you're trying to do.
@seanmonstar Hi, basically with current error_for_status_code we can only have url and status code in error message, but we are not able to understand what exactly happened.
That's why we want response body to be able to know the exact error
You could read the body and include that in your own error type.
I don't think error_for_status should default to reading the entire body, users may not require that. If you still want to use that convenience method, you could use error_for_status_ref and then still read the body.
@seanmonstar I don't think we should by default read the whole body neither, I'm wondering if you mind having a new method to manage this?
We could possibly add a new method, but I'd like to encourage trying to solve it like I mentioned first in your app/library. If it were a very common pattern, then we could consider adding it here.
@seanmonstar Thanks finally I applied your advice