Struct conjure_error::Error
source · pub struct Error(/* private fields */);
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
impl Error
sourcepub fn service<E, T>(cause: E, error_type: T) -> Error
pub fn service<E, T>(cause: E, error_type: T) -> Error
Creates a service error with an unsafe cause.
sourcepub fn service_safe<E, T>(cause: E, error_type: T) -> Error
pub fn service_safe<E, T>(cause: E, error_type: T) -> Error
Creates a service error with a safe cause.
sourcepub fn propagated_service<E>(cause: E, error: SerializableError) -> Error
pub fn propagated_service<E>(cause: E, error: SerializableError) -> Error
Creates a service error from a propagated error description and an unsafe cause.
sourcepub fn propagated_service_safe<E>(cause: E, error: SerializableError) -> Error
pub fn propagated_service_safe<E>(cause: E, error: SerializableError) -> Error
Creates a service error from a propagated error description and a safe cause.
sourcepub fn throttle<E>(cause: E) -> Error
pub fn throttle<E>(cause: E) -> Error
Creates an error indicating that the client should throttle itself with an unsafe cause.
sourcepub fn throttle_safe<E>(cause: E) -> Error
pub fn throttle_safe<E>(cause: E) -> Error
Creates an error indicating that the client should throttle itself with a safe cause.
sourcepub fn throttle_for<E>(cause: E, duration: Duration) -> Error
pub fn throttle_for<E>(cause: E, duration: Duration) -> Error
Creates an error indicating that the client should throttle itself for a specific duration with an unsafe cause.
sourcepub fn throttle_for_safe<E>(cause: E, duration: Duration) -> Error
pub fn throttle_for_safe<E>(cause: E, duration: Duration) -> Error
Creates an error indicating that the client should throttle itself for a specific duration with a safe cause.
Creates an error indicating that the server was unable to serve the client’s request with an unsafe cause.
Creates an error indicating that the server was unable to serve the client’s request with a safe cause.
sourcepub fn internal<E>(cause: E) -> Error
pub fn internal<E>(cause: E) -> Error
A convenience function to construct an internal service error with an unsafe cause.
sourcepub fn internal_safe<E>(cause: E) -> Error
pub fn internal_safe<E>(cause: E) -> Error
A convenience function to construct an internal service error with a safe cause.
sourcepub fn cause(&self) -> &(dyn Error + Sync + Send + 'static)
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.
sourcepub fn cause_safe(&self) -> bool
pub fn cause_safe(&self) -> bool
Returns whether or not the error’s cause is considered safe.
sourcepub fn with_safe_param<T>(self, key: &'static str, value: T) -> Errorwhere
T: Serialize,
pub fn with_safe_param<T>(self, key: &'static str, value: T) -> Errorwhere
T: Serialize,
sourcepub fn with_unsafe_param<T>(self, key: &'static str, value: T) -> Errorwhere
T: Serialize,
pub fn with_unsafe_param<T>(self, key: &'static str, value: T) -> Errorwhere
T: Serialize,
sourcepub fn safe_params(&self) -> Params<'_>
pub fn safe_params(&self) -> Params<'_>
Returns the error’s safe parameters.
sourcepub fn unsafe_params(&self) -> Params<'_>
pub fn unsafe_params(&self) -> Params<'_>
Returns the error’s unsafe parameters.
sourcepub fn with_backtrace(self) -> Error
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.
sourcepub fn backtraces(&self) -> &[Backtrace]
pub fn backtraces(&self) -> &[Backtrace]
Returns the error’s backtraces, ordered from oldest to newest.