pub struct Error { /* private fields */ }
Expand description

The Error struct wraps any type implementing Diagnostic into a single dynamic type.

Implementations§

source§

impl Error

Implement the Diagnostic trait as inherent methods on the Error type.

source

pub fn category(&self) -> Option<&'static Category>

Calls Diagnostic::category on the Diagnostic wrapped by this Error.

source

pub fn severity(&self) -> Severity

Calls Diagnostic::severity on the Diagnostic wrapped by this Error.

source

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

Calls Diagnostic::description on the Diagnostic wrapped by this Error.

source

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

Calls Diagnostic::message on the Diagnostic wrapped by this Error.

source

pub fn advices(&self, visitor: &mut dyn Visit) -> Result<()>

Calls Diagnostic::advices on the Diagnostic wrapped by this Error.

source

pub fn verbose_advices(&self, visitor: &mut dyn Visit) -> Result<()>

Calls Diagnostic::verbose_advices on the Diagnostic wrapped by this Error.

source

pub fn location(&self) -> Location<'_>

Calls Diagnostic::location on the Diagnostic wrapped by this Error.

source

pub fn tags(&self) -> DiagnosticTags

Calls Diagnostic::tags on the Diagnostic wrapped by this Error.

source

pub fn source(&self) -> Option<&dyn Diagnostic>

Calls Diagnostic::source on the Diagnostic wrapped by this Error.

Trait Implementations§

source§

impl AsRef<dyn Diagnostic> for Error

source§

fn as_ref(&self) -> &(dyn Diagnostic + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for Error

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for Error

§

type Target = dyn Diagnostic

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> From<T> for Error
where T: Diagnostic + Send + Sync + 'static,

Implement From for all types implementing Diagnostic, Send, Sync and outlives the 'static lifetime.

source§

fn from(diag: T) -> Self

Converts to this type from the input type.

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<E> DiagnosticExt for E
where E: AsDiagnostic,

source§

fn context<M>(self, message: M) -> Error
where E: 'static, M: Display + 'static, Error: From<ContextDiagnostic<M, E>>,

Returns a new diagnostic with the provided message as a message and description, and self as a source diagnostic. This is useful to create chains of diagnostics, where high level errors wrap lower level causes.
source§

fn with_category(self, category: &'static Category) -> Error
where Error: From<CategoryDiagnostic<E>>,

Returns a new diagnostic using the provided category if self doesn’t already have one.
source§

fn with_file_path(self, path: impl AsResource) -> Error
where Error: From<FilePathDiagnostic<E>>,

Returns a new diagnostic using the provided path if self doesn’t already have one.
source§

fn with_file_span(self, span: impl AsSpan) -> Error
where Error: From<FileSpanDiagnostic<E>>,

Returns a new diagnostic using the provided span instead of the one in self.
source§

fn with_file_source_code(self, source_code: impl AsSourceCode) -> Error
where Error: From<FileSourceCodeDiagnostic<E>>,

Returns a new diagnostic using the provided source_code if self doesn’t already have one.
source§

fn with_tags(self, tags: DiagnosticTags) -> Error
where Error: From<TagsDiagnostic<E>>,

Returns a new diagnostic with additional tags
source§

fn with_severity(self, severity: Severity) -> Error
where Error: From<SeverityDiagnostic<E>>,

Returns a new diagnostic with additional severity
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more