pub trait BackendError: Error + Sync {
type ErrorType: Debug;
// Required methods
fn new_with_traces_and_location<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
location: Option<&'static Location<'static>>,
) -> Self;
fn backtrace(&self) -> Option<&Backtrace>;
fn error_type(&self) -> &Self::ErrorType;
fn message(&self) -> &str;
fn span_trace(&self) -> &SpanTrace;
fn location(&self) -> Option<&'static Location<'static>>;
// Provided methods
fn new<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
) -> Self
where Self: Sized { ... }
fn new_with_traces<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
) -> Self
where Self: Sized { ... }
fn to_different_error<T>(
self,
new_error_type: T::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§
Sourcefn new_with_traces_and_location<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
location: Option<&'static Location<'static>>,
) -> Self
fn new_with_traces_and_location<M: Into<String>, S: Into<Option<Error>>>( error_type: Self::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, location: Option<&'static Location<'static>>, ) -> Self
The one required constructor; the others delegate to it.
fn backtrace(&self) -> Option<&Backtrace>
fn error_type(&self) -> &Self::ErrorType
fn message(&self) -> &str
fn span_trace(&self) -> &SpanTrace
Provided Methods§
Sourcefn new<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
) -> Selfwhere
Self: Sized,
fn new<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
) -> Selfwhere
Self: Sized,
Create an error, capturing the caller’s location, a backtrace and the span trace.
#[track_caller] makes Location::caller resolve to the real call site, even
through the *_err! macros, rather than to this method.
Sourcefn new_with_traces<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
) -> Selfwhere
Self: Sized,
fn new_with_traces<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
) -> Selfwhere
Self: Sized,
Like new but with an explicit backtrace and span trace, e.g. to
preserve a source error’s traces.
fn to_different_error<T>( self, new_error_type: T::ErrorType, new_message: String, ) -> T
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.