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<Error>
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Box<Error>
Create a new error with the specified kind and message
Sourcepub fn permission_denied(message: impl Into<String>) -> Box<Error>
pub fn permission_denied(message: impl Into<String>) -> Box<Error>
Create a permission denied error
Create an unavailable error
Sourcepub fn external_service(message: impl Into<String>) -> Box<Error>
pub fn external_service(message: impl Into<String>) -> Box<Error>
Create an external service error
Sourcepub fn handler(message: impl Into<String>) -> Box<Error>
pub fn handler(message: impl Into<String>) -> Box<Error>
Create a handler error - for compatibility with macro-generated code
Sourcepub fn with_context(
self: Box<Error>,
key: impl Into<String>,
value: impl Into<Value>,
) -> Box<Error>
pub fn with_context( self: Box<Error>, key: impl Into<String>, value: impl Into<Value>, ) -> Box<Error>
Add context to this error
Sourcepub fn with_operation(
self: Box<Error>,
operation: impl Into<String>,
) -> Box<Error>
pub fn with_operation( self: Box<Error>, operation: impl Into<String>, ) -> Box<Error>
Set the operation being performed
Sourcepub fn with_component(
self: Box<Error>,
component: impl Into<String>,
) -> Box<Error>
pub fn with_component( self: Box<Error>, component: impl Into<String>, ) -> Box<Error>
Set the component where error occurred
Sourcepub fn with_request_id(
self: Box<Error>,
request_id: impl Into<String>,
) -> Box<Error>
pub fn with_request_id( self: Box<Error>, request_id: impl Into<String>, ) -> Box<Error>
Set the request ID for tracing
Sourcepub fn with_user_id(self: Box<Error>, user_id: impl Into<String>) -> Box<Error>
pub fn with_user_id(self: Box<Error>, user_id: impl Into<String>) -> Box<Error>
Set the user ID
Sourcepub fn with_retry_info(self: Box<Error>, retry_info: RetryInfo) -> Box<Error>
pub fn with_retry_info(self: Box<Error>, retry_info: RetryInfo) -> Box<Error>
Add retry information
Sourcepub fn with_source(self: Box<Error>, source: Box<Error>) -> Box<Error>
pub fn with_source(self: Box<Error>, source: Box<Error>) -> Box<Error>
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