algesten / ureq

A simple, safe HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `Error::as_response`

k0nserv opened this issue · comments

Hello,

On Error there's currently a method called into_response which consumes the errors and converts it into a response, if the error occurred due to semantics of the response. However, this method consumes the errors and as such makes it impossible to e.g. check the status code while retaining the error.

The suggested as_response method would alleviate this by not consuming the error i.e.

  pub fn as_response(&self) -> Option<&Response> {
    todo!()
  }

Let me know if you like this idea and I can send a PR.

Thanks for your consideration

The Error in str0m is an enum, you can match out the status without converting. We could of course make a helper.

Ah right, I'm just being a dummy 🤦‍♂️