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§


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("")
    // Transport errors, such as DNS or connectivity problems
    // must still be dealt with as `Err`.

assert_eq!(response.status(), 500);

Implementations on Foreign Types§


impl OrAnyStatus for Result<Response, Error>