pub enum AwpError {
InvalidRequest(String),
Unauthorized(String),
Forbidden(String),
NotFound(String),
RateLimited {
retry_after_secs: u64,
},
VersionMismatch {
requested: AwpVersion,
current: AwpVersion,
},
InternalError(String),
ServiceUnavailable(String),
}Expand description
AWP protocol error with HTTP status code mapping.
Each variant maps to a specific HTTP status code via AwpError::status_code()
and a snake_case error code via AwpError::error_code().
§Example
use awp_types::AwpError;
let err = AwpError::NotFound("resource xyz".to_string());
assert_eq!(err.status_code(), 404);
assert_eq!(err.error_code(), "not_found");Variants§
InvalidRequest(String)
Forbidden(String)
NotFound(String)
RateLimited
VersionMismatch
InternalError(String)
Implementations§
Source§impl AwpError
impl AwpError
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Returns the HTTP status code corresponding to this error variant.
Sourcepub fn error_code(&self) -> &str
pub fn error_code(&self) -> &str
Returns a snake_case error code string for this variant.
Trait Implementations§
Source§impl Error for AwpError
impl Error for AwpError
1.30.0 · 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()
impl Eq for AwpError
impl StructuralPartialEq for AwpError
Auto Trait Implementations§
impl Freeze for AwpError
impl RefUnwindSafe for AwpError
impl Send for AwpError
impl Sync for AwpError
impl Unpin for AwpError
impl UnsafeUnpin for AwpError
impl UnwindSafe for AwpError
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