pub enum TypecastError {
BadRequest {
detail: String,
},
Unauthorized {
detail: String,
},
PaymentRequired {
detail: String,
},
Forbidden {
detail: String,
},
NotFound {
detail: String,
},
ValidationError {
detail: String,
},
RateLimited {
detail: String,
},
ServerError {
detail: String,
},
HttpError(Error),
JsonError(Error),
Unknown {
status_code: u16,
detail: String,
},
}Expand description
Error type for Typecast API operations
Variants§
BadRequest
Bad Request - The request was invalid or cannot be served
Unauthorized - Invalid or missing API key
Fields
PaymentRequired
Payment Required - Insufficient credits to complete the request
Forbidden
Forbidden - Access denied
NotFound
Not Found - The requested resource does not exist
ValidationError
Validation Error - The request data failed validation
RateLimited
Too Many Requests - Rate limit exceeded
ServerError
Internal Server Error - Something went wrong on the server
HttpError(Error)
HTTP client error
JsonError(Error)
JSON serialization/deserialization error
Unknown
Unknown error with status code
Implementations§
Source§impl TypecastError
impl TypecastError
Sourcepub fn from_response(
status_code: u16,
error_response: Option<ErrorResponse>,
) -> Self
pub fn from_response( status_code: u16, error_response: Option<ErrorResponse>, ) -> Self
Create an error from an HTTP response status code and optional error response
Sourcepub fn is_bad_request(&self) -> bool
pub fn is_bad_request(&self) -> bool
Check if this error is a bad request error
Check if this error is an unauthorized error
Sourcepub fn is_payment_required(&self) -> bool
pub fn is_payment_required(&self) -> bool
Check if this error is a payment required error
Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
Check if this error is a forbidden error
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Check if this error is a not found error
Sourcepub fn is_validation_error(&self) -> bool
pub fn is_validation_error(&self) -> bool
Check if this error is a validation error
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Check if this error is a rate limit error
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this error is a server error
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Get the status code if available
Trait Implementations§
Source§impl Debug for TypecastError
impl Debug for TypecastError
Source§impl Display for TypecastError
impl Display for TypecastError
Source§impl Error for TypecastError
impl Error for TypecastError
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()
Source§impl From<Error> for TypecastError
impl From<Error> for TypecastError
Auto Trait Implementations§
impl Freeze for TypecastError
impl !RefUnwindSafe for TypecastError
impl Send for TypecastError
impl Sync for TypecastError
impl Unpin for TypecastError
impl UnsafeUnpin for TypecastError
impl !UnwindSafe for TypecastError
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.