pub struct Error {
pub error: Error,
pub trace: Trace<PathBuf>,
/* private fields */
}Available on crate feature
file only.Expand description
Error for the File evaluator.
§Example
use module_util::evaluator::dfs;
let mut err = Error::new(dfs::Error::Merge({
let mut e = module::merge::Error::collision();
e.field.push_back("my");
e.field.push_back("super");
e.field.push_back("awesome");
e.field.push_back("field");
e
}));
err.trace.push("module 1".into());
err.trace.push("module 2".into());
err.trace.push("module 3".into());
assert_eq!(format!("{err}"),
r#"value collision while evaluating "my.super.awesome.field"
in module 3
from module 2
from module 1
"#);
assert_eq!(format!("{err}"), format!("{err:#}"));use module_util::evaluator::dfs;
let mut err = Error::new(dfs::Error::Merge(module::merge::Error::collision()));
err.trace.push("module 1".into());
assert_eq!(format!("{err}"),
r#"value collision
in module 1
"#);
assert_eq!(format!("{err}"), format!("{err:#}"));use module_util::evaluator::dfs;
use std::io;
let mut err = Error::new({
let mut e = module::merge::Error::other(io::Error::other("invalid data"));
e.field.push_back("user");
e.field.push_back("email");
dfs::Error::Merge(e)
});
err.trace.push("module 1".into());
err.trace.push("module 2".into());
assert_eq!(format!("{err}"),
r#"invalid data while evaluating "user.email"
in module 2
from module 1
"#);
assert_eq!(format!("{err}"), format!("{err:#}"));use module_util::evaluator::{dfs, Trace};
use std::io;
let err = Error::new(dfs::Error::other(io::Error::other("some other error")))
.with_trace({
let mut t = Trace::empty();
t.push("module 1".into());
t.push("module 2".into());
t.push("module 3".into());
t
});
assert_eq!(format!("{err}"),
r#"some other error
in module 3
from module 2
from module 1
"#);
assert_eq!(format!("{err}"), format!("{err:#}"));Fields§
§error: ErrorEvaluation error.
trace: Trace<PathBuf>Module trace.
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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