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
MacroOutput
s.
Implementations§
source§impl ErrorMessage
impl ErrorMessage
sourcepub fn new(span: impl SpanRanged, msg: impl Display) -> Self
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.
sourcepub fn spanned(tokens: impl ToTokens, msg: impl Display) -> Self
pub fn spanned(tokens: impl ToTokens, msg: impl Display) -> Self
Creates an error message pointing to the complete token stream tokens
expands to
sourcepub fn call_site(msg: impl Display) -> Self
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.
sourcepub fn attachment(self, label: &'static str, msg: impl Display) -> Self
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
.
sourcepub fn error(self, msg: impl Display) -> Self
pub fn error(self, msg: impl Display) -> Self
Attaches a new error
message to self
reusing the same span
sourcepub fn warning(self, msg: impl Display) -> Self
pub fn warning(self, msg: impl Display) -> Self
Attaches a new warning
message to self
reusing the same span
Trait Implementations§
source§impl Attachment for ErrorMessage
impl Attachment for ErrorMessage
source§fn attachment(self, label: &'static str, msg: impl Display) -> Self
fn attachment(self, label: &'static str, msg: impl Display) -> Self
self
reusing the same
span, and the specified label
.source§impl Debug for ErrorMessage
impl Debug for ErrorMessage
source§impl Display for ErrorMessage
impl Display for ErrorMessage
source§impl From<ErrorMessage> for Error
impl From<ErrorMessage> for Error
source§fn from(error: ErrorMessage) -> Self
fn from(error: ErrorMessage) -> Self
source§impl From<ErrorMessage> for Error
Available on crate feature syn2
only.
impl From<ErrorMessage> for Error
syn2
only.source§fn from(value: ErrorMessage) -> Self
fn from(value: ErrorMessage) -> Self
source§impl ToTokensError for ErrorMessage
impl ToTokensError for ErrorMessage
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
ToTokens::to_tokens
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
ToTokens::to_token_stream
source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
ToTokens::into_token_stream