Struct conjure_error::Error

source ·
pub struct Error(_);
Expand description

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.

Implementations§

source§

impl Error

source

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

Creates a service error with an unsafe cause.

source

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

Creates a service error with a safe cause.

source

pub fn propagated_service<E>(cause: E, error: SerializableError) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

Creates a service error from a propagated error description and an unsafe cause.

source

pub fn propagated_service_safe<E>(cause: E, error: SerializableError) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

Creates a service error from a propagated error description and a safe cause.

source

pub fn throttle<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

pub fn throttle_safe<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

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

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

source

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

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

source

pub fn unavailable<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

pub fn unavailable_safe<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

pub fn internal<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

pub fn internal_safe<E>(cause: E) -> Errorwhere E: Into<Box<dyn Error + Sync + Send>>,

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

source

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

Returns the error’s cause.

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

source

pub fn cause_safe(&self) -> bool

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

source

pub fn kind(&self) -> &ErrorKind

Returns kind-specific error information.

source

pub fn with_safe_param<T>(self, key: &'static str, value: T) -> Errorwhere T: Serialize,

Adds a new safe parameter to the error.

Panics

Panics if the value fails to serialize.

source

pub fn with_unsafe_param<T>(self, key: &'static str, value: T) -> Errorwhere T: Serialize,

Adds a new unsafe parameter to the error.

Panics

Panics if the value fails to serialize.

source

pub fn safe_params(&self) -> Params<'_>

Returns the error’s safe parameters.

source

pub fn unsafe_params(&self) -> Params<'_>

Returns the error’s unsafe parameters.

source

pub fn with_backtrace(self) -> Error

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.

source

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

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

Trait Implementations§

source§

impl Debug for Error

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.