#[non_exhaustive]pub enum Error {
Api(Box<ApiError>),
Configuration(String),
Authentication(String),
Validation(String),
NotFound(String),
Operation {
kind: ErrorKind,
code: String,
message: String,
},
Timeout {
method: String,
path: String,
elapsed: Duration,
},
Network {
method: String,
path: String,
source: Error,
},
Decode {
context: String,
source: Error,
},
Encode {
source: Error,
},
}Expand description
The error type returned by every fallible SDK call.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api(Box<ApiError>)
The API responded with a non-2xx status.
Boxed so that Result<T> stays small on the happy path, which every
call in the crate pays for.
Configuration(String)
The client was constructed or used with invalid configuration.
Authentication(String)
A token could not be verified (malformed, bad signature, or expired).
Validation(String)
A client-side precondition failed before the request was sent.
NotFound(String)
The SDK resolved that a resource does not exist without the API saying so, e.g. asking for a participant in a room that has no live session.
Operation
A multi-step operation the SDK drives to completion failed, e.g. a batch-call file that the server could not parse.
Carries a machine-readable code but no HTTP status,
since the failure is a result rather than a response.
Fields
Timeout
The client-side request timeout elapsed.
Fields
Network
The request could not be sent, or the response could not be read.
Fields
Decode
A response body could not be deserialized into the expected type.
Fields
Encode
A request body could not be serialized.
Implementations§
Source§impl Error
impl Error
Sourcepub fn as_api(&self) -> Option<&ApiError>
pub fn as_api(&self) -> Option<&ApiError>
The underlying ApiError, if this error came from an HTTP response.
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
The HTTP status code, if this error came from an HTTP response.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The server request id, if the response carried one.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The cooldown the server asked for via Retry-After on a 429.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Whether this is a not-found error (HTTP 404 or 402).
Sourcepub fn is_authentication(&self) -> bool
pub fn is_authentication(&self) -> bool
Whether this is an authentication error (HTTP 401, or a bad token).
Sourcepub fn is_permission(&self) -> bool
pub fn is_permission(&self) -> bool
Whether this is a permission error (HTTP 403).
Sourcepub fn is_validation(&self) -> bool
pub fn is_validation(&self) -> bool
Whether this is a validation error (HTTP 400, or a client-side check).
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Whether this is a rate-limit error (HTTP 429).
Sourcepub fn is_conflict(&self) -> bool
pub fn is_conflict(&self) -> bool
Whether this is a conflict error (HTTP 409).
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Whether this is a client-side timeout.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()