Struct lazy_errors::AdHocError
source · pub struct AdHocError { /* private fields */ }
Expand description
A single, “one of a kind” Error
, created from an ad-hoc error message,
with source location information that gets added implicitly
when a value of this type is constructed.
Most of the time this type is used only internally.
Values of this type get created internally
when the err!
macro or
when Error::from_message
are called.
AdHocError
can be printed and supports “pretty-printing” as well:
use lazy_errors::AdHocError;
let err = AdHocError::from_message("Something went wrong");
let printed = format!("{err}");
assert_eq!(printed, "Something went wrong");
let printed = format!("{err:#}");
let printed = replace_line_numbers(&printed);
assert_eq!(printed, indoc::indoc! {"
Something went wrong
at src/error.rs:1234:56"});
Implementations§
source§impl AdHocError
impl AdHocError
sourcepub fn from_message<M: Display>(msg: M) -> Self
pub fn from_message<M: Display>(msg: M) -> Self
Creates an AdHocError
from a message.
Trait Implementations§
source§impl Debug for AdHocError
impl Debug for AdHocError
source§impl Display for AdHocError
impl Display for AdHocError
source§impl Error for AdHocError
impl Error for AdHocError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl IntoEyreReport for AdHocError
impl IntoEyreReport for AdHocError
source§fn into_eyre_report(self) -> Report
fn into_eyre_report(self) -> Report
Lossy conversion to return some type, for example
a non-empty list of one or more errors,
from functions returning
eyre::Result
,
i.e. Result<_, E>
where E
is eyre::Report
. Read moreimpl Reportable for AdHocError
Auto Trait Implementations§
impl Freeze for AdHocError
impl RefUnwindSafe for AdHocError
impl Send for AdHocError
impl Sync for AdHocError
impl Unpin for AdHocError
impl UnwindSafe for AdHocError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more