pub struct Error {
pub id: Uuid,
pub kind: ErrorKind,
pub message: String,
pub context: ErrorContext,
pub source: Option<Box<Error>>,
pub backtrace: Backtrace,
}
Expand description
Comprehensive error type with rich context information
Fields§
§id: Uuid
Unique identifier for this error instance
kind: ErrorKind
Error classification
message: String
Human-readable error message
context: ErrorContext
Additional contextual information
source: Option<Box<Error>>
Optional source error that caused this error
backtrace: Backtrace
Stack trace information (when available)
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> Box<Self>
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Box<Self>
Create a new error with the specified kind and message
Sourcepub fn validation(message: impl Into<String>) -> Box<Self>
pub fn validation(message: impl Into<String>) -> Box<Self>
Create a validation error
Sourcepub fn authentication(message: impl Into<String>) -> Box<Self>
pub fn authentication(message: impl Into<String>) -> Box<Self>
Create an authentication error
Sourcepub fn permission_denied(message: impl Into<String>) -> Box<Self>
pub fn permission_denied(message: impl Into<String>) -> Box<Self>
Create a permission denied error
Sourcepub fn bad_request(message: impl Into<String>) -> Box<Self>
pub fn bad_request(message: impl Into<String>) -> Box<Self>
Create a bad request error
Sourcepub fn serialization(message: impl Into<String>) -> Box<Self>
pub fn serialization(message: impl Into<String>) -> Box<Self>
Create a serialization error
Create an unavailable error
Sourcepub fn rate_limited(message: impl Into<String>) -> Box<Self>
pub fn rate_limited(message: impl Into<String>) -> Box<Self>
Create a rate limited error
Sourcepub fn configuration(message: impl Into<String>) -> Box<Self>
pub fn configuration(message: impl Into<String>) -> Box<Self>
Create a configuration error
Sourcepub fn external_service(message: impl Into<String>) -> Box<Self>
pub fn external_service(message: impl Into<String>) -> Box<Self>
Create an external service error
Sourcepub fn handler(message: impl Into<String>) -> Box<Self>
pub fn handler(message: impl Into<String>) -> Box<Self>
Create a handler error - for compatibility with macro-generated code
Sourcepub fn with_context(
self: Box<Self>,
key: impl Into<String>,
value: impl Into<Value>,
) -> Box<Self>
pub fn with_context( self: Box<Self>, key: impl Into<String>, value: impl Into<Value>, ) -> Box<Self>
Add context to this error
Sourcepub fn with_operation(
self: Box<Self>,
operation: impl Into<String>,
) -> Box<Self>
pub fn with_operation( self: Box<Self>, operation: impl Into<String>, ) -> Box<Self>
Set the operation being performed
Sourcepub fn with_component(
self: Box<Self>,
component: impl Into<String>,
) -> Box<Self>
pub fn with_component( self: Box<Self>, component: impl Into<String>, ) -> Box<Self>
Set the component where error occurred
Sourcepub fn with_request_id(
self: Box<Self>,
request_id: impl Into<String>,
) -> Box<Self>
pub fn with_request_id( self: Box<Self>, request_id: impl Into<String>, ) -> Box<Self>
Set the request ID for tracing
Sourcepub fn with_retry_info(self: Box<Self>, retry_info: RetryInfo) -> Box<Self>
pub fn with_retry_info(self: Box<Self>, retry_info: RetryInfo) -> Box<Self>
Add retry information
Sourcepub fn with_source(self: Box<Self>, source: Box<Self>) -> Box<Self>
pub fn with_source(self: Box<Self>, source: Box<Self>) -> Box<Self>
Chain this error with a source error
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Check if this error is retryable based on its kind
Sourcepub const fn is_temporary(&self) -> bool
pub const fn is_temporary(&self) -> bool
Check if this error indicates a temporary failure
Sourcepub const fn http_status_code(&self) -> u16
pub const fn http_status_code(&self) -> u16
Get the HTTP status code equivalent for this error
Sourcepub const fn jsonrpc_error_code(&self) -> i32
pub const fn jsonrpc_error_code(&self) -> i32
Convert to a JSON-RPC error code