pub enum DarkStrataError {
Authentication {
message: String,
status_code: Option<u16>,
},
Validation {
message: String,
field: Option<String>,
},
Api {
message: String,
status_code: Option<u16>,
retryable: bool,
},
Timeout {
duration: Duration,
},
Network {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
RateLimit {
retry_after: Option<Duration>,
},
}Expand description
Main error type for the DarkStrata SDK.
Variants§
Authentication
Authentication failed (invalid or missing API key).
Validation
Input validation failed.
Fields
Api
API request failed.
Fields
Timeout
Request timed out.
Network
Network connectivity error.
Fields
RateLimit
Rate limit exceeded.
Implementations§
Source§impl DarkStrataError
impl DarkStrataError
Sourcepub fn authentication(message: impl Into<String>) -> Self
pub fn authentication(message: impl Into<String>) -> Self
Create an authentication error.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a validation error.
Sourcepub fn validation_field(
field: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn validation_field( field: impl Into<String>, message: impl Into<String>, ) -> Self
Create a validation error for a specific field.
Sourcepub fn network_with_source(
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn network_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create a network error with a source.
Sourcepub fn rate_limit(retry_after: Option<Duration>) -> Self
pub fn rate_limit(retry_after: Option<Duration>) -> Self
Create a rate limit error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Get the HTTP status code if available.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Get the retry-after duration for rate limit errors.
Trait Implementations§
Source§impl Debug for DarkStrataError
impl Debug for DarkStrataError
Source§impl Display for DarkStrataError
impl Display for DarkStrataError
Source§impl Error for DarkStrataError
impl Error for DarkStrataError
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()
Auto Trait Implementations§
impl Freeze for DarkStrataError
impl !RefUnwindSafe for DarkStrataError
impl Send for DarkStrataError
impl Sync for DarkStrataError
impl Unpin for DarkStrataError
impl UnsafeUnpin for DarkStrataError
impl !UnwindSafe for DarkStrataError
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
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.