Skip to main content

ErrorExt

Trait ErrorExt 

Source
pub trait ErrorExt: StackError {
    // Required method
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn status_code(&self) -> StatusCode { ... }
    fn retry_hint(&self) -> RetryHint { ... }
    fn is_retryable(&self) -> bool { ... }
    fn output_msg(&self) -> String
       where Self: Sized { ... }
    fn root_cause(&self) -> Option<&dyn Error>
       where Self: Sized { ... }
}
Expand description

Extension to Error in std.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns the error as Any so that it can be downcast to a specific implementation.

Provided Methods§

Source

fn status_code(&self) -> StatusCode

Map this error to StatusCode.

Source

fn retry_hint(&self) -> RetryHint

Returns the retry hint for this error instance.

Implementations should return RetryHint::Retryable only when retrying the same operation may succeed without changing the request. The default is RetryHint::NonRetryable to avoid accidental retry loops.

Source

fn is_retryable(&self) -> bool

Returns whether this error instance is marked retryable.

This is derived from Self::retry_hint. Transport-level retries, such as a gRPC Unavailable, may still be handled separately by client code.

Source

fn output_msg(&self) -> String
where Self: Sized,

Source

fn root_cause(&self) -> Option<&dyn Error>
where Self: Sized,

Find out root level error for nested error

Implementors§