pub struct ApiCallError {
pub message: String,
pub url: Url,
pub request_body: Option<JsonValue>,
pub status_code: Option<StatusCode>,
pub response_headers: Option<Headers>,
pub response_body: Option<String>,
pub is_retryable: bool,
pub data: Option<JsonValue>,
pub cause: Option<BoxError>,
}Expand description
An HTTP request to the provider failed or returned an error status.
Fields§
§message: StringHuman-readable message (no secrets, no full bodies).
url: UrlRequest URL.
request_body: Option<JsonValue>JSON request body that was sent, if any.
status_code: Option<StatusCode>HTTP status code, if a response was received.
response_headers: Option<Headers>Response headers, if a response was received.
response_body: Option<String>Raw response body text, if a response was received.
is_retryable: boolWhether retrying may succeed.
data: Option<JsonValue>Structured error payload parsed from the response, if any.
cause: Option<BoxError>Underlying cause (network error, JSON error, …).
Implementations§
Source§impl ApiCallError
impl ApiCallError
Sourcepub fn new(message: impl Into<String>, url: Url) -> Self
pub fn new(message: impl Into<String>, url: Url) -> Self
Creates an error without a response; retryable by default.
Sourcepub fn with_status(self, status_code: StatusCode) -> Self
pub fn with_status(self, status_code: StatusCode) -> Self
Sets the status code and recomputes the default retry classification.
Sourcepub fn with_request_body(self, body: JsonValue) -> Self
pub fn with_request_body(self, body: JsonValue) -> Self
Sets the request body.
Sourcepub fn with_response(self, headers: Headers, body: Option<String>) -> Self
pub fn with_response(self, headers: Headers, body: Option<String>) -> Self
Sets response headers and body.
Sourcepub fn with_cause(self, cause: impl Error + Send + Sync + 'static) -> Self
pub fn with_cause(self, cause: impl Error + Send + Sync + 'static) -> Self
Sets the underlying cause.
Trait Implementations§
Source§impl Debug for ApiCallError
impl Debug for ApiCallError
Source§impl Display for ApiCallError
impl Display for ApiCallError
Source§impl Error for ApiCallError
impl Error for ApiCallError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ApiCallError> for ProviderError
impl From<ApiCallError> for ProviderError
Source§fn from(error: ApiCallError) -> Self
fn from(error: ApiCallError) -> Self
Converts to this type from the input type.
Source§impl From<Box<ApiCallError>> for ProviderError
impl From<Box<ApiCallError>> for ProviderError
Source§fn from(error: Box<ApiCallError>) -> Self
fn from(error: Box<ApiCallError>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for ApiCallError
impl !UnwindSafe for ApiCallError
impl Freeze for ApiCallError
impl Send for ApiCallError
impl Sync for ApiCallError
impl Unpin for ApiCallError
impl UnsafeUnpin for ApiCallError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more