#[non_exhaustive]pub enum Error {
Api {
code: i64,
message: String,
request_id: Option<String>,
body_snippet: Option<String>,
},
Auth(HttpError),
NotFound(HttpError),
Conflict(HttpError),
RateLimited {
error: HttpError,
retry_after: Option<Duration>,
},
Transport(Box<TransportError>),
Serialization(Error),
Timestamp(SystemTimeError),
Signature,
InvalidConfig {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
}Expand description
SDK error type and helpers. Unified SDK error type.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Api
API business error returned by DingTalk.
Fields
Auth(HttpError)
Authentication/authorization HTTP error.
NotFound(HttpError)
Not-found HTTP error.
Conflict(HttpError)
Conflict HTTP error.
RateLimited
Rate limit error with optional retry hint.
Fields
Transport(Box<TransportError>)
Transport error from HTTP runtime/client.
Serialization(Error)
JSON serialization/deserialization error.
Timestamp(SystemTimeError)
System timestamp retrieval error.
Signature
Signature generation error.
InvalidConfig
Invalid runtime configuration.
Implementations§
Source§impl Error
impl Error
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns DingTalk/transport request-id when present.
Sourcepub fn body_snippet(&self) -> Option<&str>
pub fn body_snippet(&self) -> Option<&str>
Returns redacted body snippet when retained by the SDK.
Sourcepub fn is_auth_error(&self) -> bool
pub fn is_auth_error(&self) -> bool
Returns true if the error is an auth/authz failure.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the error is likely transient and safe to retry.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Returns retry-after hint when the upstream provided one.
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)>
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<SystemTimeError> for Error
impl From<SystemTimeError> for Error
Source§fn from(source: SystemTimeError) -> Self
fn from(source: SystemTimeError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
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