[][src]Struct conjure_error::Error

pub struct Error(_);

A standard error type for network services.

An error consists of several components:

  • The cause of the error, represented as a type implementing the Rust Error trait. The cause can either be declared safe or unsafe to log.
  • The error's kind, indicating how the service should handle the error e.g. in a response to a client.
  • Backtraces, including one taken at the time the error was created.
  • Parameters adding extra context about the error. They can be declared either safe or unsafe to log.

Note that this type does not implement the standard library's Error trait.

Methods

impl Error[src]

pub fn service<E, T>(cause: E, error_type: T) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>,
    T: ErrorType + Serialize
[src]

Creates a service error with an unsafe cause.

pub fn service_safe<E, T>(cause: E, error_type: T) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>,
    T: ErrorType + Serialize
[src]

Creates a service error with a safe cause.

pub fn throttle<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the client should throttle itself with an unsafe cause.

pub fn throttle_safe<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the client should throttle itself with a safe cause.

pub fn throttle_for<E>(cause: E, duration: Duration) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the client should throttle itself for a specific duration with an unsafe cause.

pub fn throttle_for_safe<E>(cause: E, duration: Duration) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the client should throttle itself for a specific duration with a safe cause.

pub fn unavailable<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the server was unable to serve the client's request with an unsafe cause.

pub fn unavailable_safe<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

Creates an error indicating that the server was unable to serve the client's request with a safe cause.

pub fn internal<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

A convenience function to construct an internal service error with an unsafe cause.

pub fn internal_safe<E>(cause: E) -> Error where
    E: Into<Box<dyn Error + Sync + Send>>, 
[src]

A convenience function to construct an internal service error with a safe cause.

pub fn cause(&self) -> &(dyn Error + Sync + Send + 'static)[src]

Returns the error's cause.

Use the cause_safe method to determine if the error is safe or not.

pub fn cause_safe(&self) -> bool[src]

Returns whether or not the error's cause is considered safe.

pub fn kind(&self) -> &ErrorKind[src]

Returns kind-specific error information.

pub fn with_safe_param<T>(self, key: &'static str, value: T) -> Error where
    T: Serialize
[src]

Adds a new safe parameter to the error.

Panics

Panics if the value fails to serialize.

pub fn with_unsafe_param<T>(self, key: &'static str, value: T) -> Error where
    T: Serialize
[src]

Adds a new unsafe parameter to the error.

Panics

Panics if the value fails to serialize.

pub fn safe_params(&self) -> Params[src]

Returns the error's safe parameters.

pub fn unsafe_params(&self) -> Params[src]

Returns the error's unsafe parameters.

pub fn with_backtrace(self) -> Error[src]

Adds a new backtrace to the error.

An error always takes a backtrace at the time of its construction, but this method can be used to add extra backtraces to it. For example, this might be used when transferring an error from one thread to another.

pub fn backtraces(&self) -> &[Backtrace][src]

Returns the error's backtraces, ordered from oldest to newest.

Trait Implementations

impl Debug for Error[src]

Auto Trait Implementations

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl !UnwindSafe for Error

impl !RefUnwindSafe for Error

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]