Struct manyhow::ErrorMessage

source ·
pub struct ErrorMessage { /* private fields */ }
Expand description

A single error message

Can take additional attachments like help or note.

Implements ToTokensError and can therefore be used with MacroOutputs.

Implementations§

source§

impl ErrorMessage

source

pub fn new(span: impl SpanRanged, msg: impl Display) -> Self

Creates a new error message at the specified span

This function takes a SpanRanged meaning you can also pass a Range<Span> (i.e. first..last) for better error messages on multi token values, for details see SpanRanged#motivation

If your type implements ToTokens use ErrorMessage::spanned instead.

source

pub fn spanned(tokens: impl ToTokens, msg: impl Display) -> Self

Creates an error message pointing to the complete token stream tokens expands to

source

pub fn call_site(msg: impl Display) -> Self

Creates a new error message at Span::call_site prefer ErrorMessage::new or ErrorMessage::spanned with the correct span for a more helpful output.

source

pub fn attachment(self, label: &'static str, msg: impl Display) -> Self

Attaches an additional message to self reusing the same span, and the specified label.

source

pub fn error(self, msg: impl Display) -> Self

Attaches a new error message to self reusing the same span

source

pub fn warning(self, msg: impl Display) -> Self

Attaches a new warning message to self reusing the same span

source

pub fn note(self, msg: impl Display) -> Self

Attaches a new note message to self reusing the same span

source

pub fn help(self, msg: impl Display) -> Self

Attaches a new help message to self reusing the same span

Trait Implementations§

source§

impl Attachment for ErrorMessage

source§

fn attachment(self, label: &'static str, msg: impl Display) -> Self

Attaches an additional message to self reusing the same span, and the specified label.
source§

impl Debug for ErrorMessage

source§

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

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

impl Display for ErrorMessage

source§

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

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

impl From<ErrorMessage> for Error

source§

fn from(error: ErrorMessage) -> Self

Converts to this type from the input type.
source§

impl From<ErrorMessage> for Error

Available on crate feature syn2 only.
source§

fn from(value: ErrorMessage) -> Self

Converts to this type from the input type.
source§

impl ToTokensError for ErrorMessage

Auto Trait Implementations§

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> JoinToTokensError for T
where T: ToTokensError + 'static,

source§

fn join(self, error: impl ToTokensError + 'static) -> Error

Joins two Errors Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.