Error

Struct Error 

Source
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

Source

pub fn new(kind: ErrorKind, message: impl Into<String>) -> Box<Self>

Create a new error with the specified kind and message

Source

pub fn validation(message: impl Into<String>) -> Box<Self>

Create a validation error

Source

pub fn authentication(message: impl Into<String>) -> Box<Self>

Create an authentication error

Source

pub fn not_found(message: impl Into<String>) -> Box<Self>

Create a not found error

Source

pub fn permission_denied(message: impl Into<String>) -> Box<Self>

Create a permission denied error

Source

pub fn bad_request(message: impl Into<String>) -> Box<Self>

Create a bad request error

Source

pub fn internal(message: impl Into<String>) -> Box<Self>

Create an internal error

Source

pub fn transport(message: impl Into<String>) -> Box<Self>

Create a transport error

Source

pub fn serialization(message: impl Into<String>) -> Box<Self>

Create a serialization error

Source

pub fn protocol(message: impl Into<String>) -> Box<Self>

Create a protocol error

Source

pub fn rpc(code: i32, message: &str) -> Box<Self>

Create a JSON-RPC error

Source

pub fn timeout(message: impl Into<String>) -> Box<Self>

Create a timeout error

Source

pub fn unavailable(message: impl Into<String>) -> Box<Self>

Create an unavailable error

Source

pub fn rate_limited(message: impl Into<String>) -> Box<Self>

Create a rate limited error

Source

pub fn configuration(message: impl Into<String>) -> Box<Self>

Create a configuration error

Source

pub fn external_service(message: impl Into<String>) -> Box<Self>

Create an external service error

Source

pub fn cancelled(message: impl Into<String>) -> Box<Self>

Create a cancelled error

Source

pub fn handler(message: impl Into<String>) -> Box<Self>

Create a handler error - for compatibility with macro-generated code

Source

pub fn with_context( self: Box<Self>, key: impl Into<String>, value: impl Into<Value>, ) -> Box<Self>

Add context to this error

Source

pub fn with_operation( self: Box<Self>, operation: impl Into<String>, ) -> Box<Self>

Set the operation being performed

Source

pub fn with_component( self: Box<Self>, component: impl Into<String>, ) -> Box<Self>

Set the component where error occurred

Source

pub fn with_request_id( self: Box<Self>, request_id: impl Into<String>, ) -> Box<Self>

Set the request ID for tracing

Source

pub fn with_user_id(self: Box<Self>, user_id: impl Into<String>) -> Box<Self>

Set the user ID

Source

pub fn with_retry_info(self: Box<Self>, retry_info: RetryInfo) -> Box<Self>

Add retry information

Source

pub fn with_source(self: Box<Self>, source: Box<Self>) -> Box<Self>

Chain this error with a source error

Source

pub const fn is_retryable(&self) -> bool

Check if this error is retryable based on its kind

Source

pub const fn is_temporary(&self) -> bool

Check if this error indicates a temporary failure

Source

pub const fn http_status_code(&self) -> u16

Get the HTTP status code equivalent for this error

Source

pub const fn jsonrpc_error_code(&self) -> i32

Convert to a JSON-RPC error code

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Error

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Box<Error>

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Box<Error>

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl Serialize for Error

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl !Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,