headless_lms_server::prelude

Trait BackendError

Source
pub trait BackendError: Error + Sync {
    type ErrorType: Debug;

    // Required methods
    fn new<M, S>(
        error_type: Self::ErrorType,
        message: M,
        source_error: S,
    ) -> Self
       where M: Into<String>,
             S: Into<Option<Error>>;
    fn new_with_traces<M, S>(
        error_type: Self::ErrorType,
        message: M,
        source_error: S,
        backtrace: Backtrace,
        span_trace: SpanTrace,
    ) -> Self
       where M: Into<String>,
             S: Into<Option<Error>>;
    fn backtrace(&self) -> Option<&Backtrace>;
    fn error_type(&self) -> &Self::ErrorType;
    fn message(&self) -> &str;
    fn span_trace(&self) -> &SpanTrace;

    // Provided method
    fn to_different_error<T>(
        self,
        new_error_type: <T as BackendError>::ErrorType,
        new_message: String,
    ) -> T
       where T: BackendError,
             Self: Sized + 'static + Send { ... }
}
Expand description

The error types of this program all implement this trait for interoperability.

Required Associated Types§

Required Methods§

Source

fn new<M, S>(error_type: Self::ErrorType, message: M, source_error: S) -> Self
where M: Into<String>, S: Into<Option<Error>>,

Source

fn new_with_traces<M, S>( error_type: Self::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, ) -> Self
where M: Into<String>, S: Into<Option<Error>>,

Source

fn backtrace(&self) -> Option<&Backtrace>

Source

fn error_type(&self) -> &Self::ErrorType

Source

fn message(&self) -> &str

Source

fn span_trace(&self) -> &SpanTrace

Provided Methods§

Source

fn to_different_error<T>( self, new_error_type: <T as BackendError>::ErrorType, new_message: String, ) -> T
where T: BackendError, Self: Sized + 'static + Send,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BackendError for ModelError

Source§

type ErrorType = ModelErrorType

Source§

fn new<M, S>( error_type: <ModelError as BackendError>::ErrorType, message: M, source_error: S, ) -> ModelError
where M: Into<String>, S: Into<Option<Error>>,

Source§

fn backtrace(&self) -> Option<&Backtrace>

Source§

fn error_type(&self) -> &<ModelError as BackendError>::ErrorType

Source§

fn message(&self) -> &str

Source§

fn span_trace(&self) -> &SpanTrace

Source§

fn new_with_traces<M, S>( error_type: <ModelError as BackendError>::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, ) -> ModelError
where M: Into<String>, S: Into<Option<Error>>,

Implementors§