Trait ureq::OrAnyStatus
source · pub trait OrAnyStatus {
// Required method
fn or_any_status(self) -> Result<Response, Transport>;
}Expand description
Extension to Result<Response, Error> for handling all status codes as Response.
Required Methods§
sourcefn or_any_status(self) -> Result<Response, Transport>
fn or_any_status(self) -> Result<Response, Transport>
Ergonomic helper for handling all status codes as Response.
By default, ureq returns non-2xx responses as Error::Status. This
helper is for handling all responses as Response, regardless
of status code.
// Bring trait into context.
use ureq::OrAnyStatus;
let response = ureq::get("http://httpbin.org/status/500")
.call()
// Transport errors, such as DNS or connectivity problems
// must still be dealt with as `Err`.
.or_any_status()?;
assert_eq!(response.status(), 500);