pub struct UserError { /* private fields */ }
Expand description
A human-readable error interface.
use uerr::UserError;
UserError::from("could not open file")
.and_reason("The system cannot find the file specified.")
.and_help("Does this file exist?")
.print_all("uerr/error: ")
.exit(1);
Implementations
sourceimpl UserError
impl UserError
sourcepub fn print_all<D>(&self, prefix: D) -> &Self where
D: Display,
pub fn print_all<D>(&self, prefix: D) -> &Self where
D: Display,
Print the given prefix followed by the contained error message.
No padding is inserted between either elements.
sourcepub fn add_reason(&mut self, reason: impl Into<String>)
pub fn add_reason(&mut self, reason: impl Into<String>)
Add a reason to this UserError.
sourcepub fn and_help(self, help: impl Into<String>) -> Self
pub fn and_help(self, help: impl Into<String>) -> Self
Add a help tip to this UserError.
Returns the current instance.
sourcepub fn and_reason(self, reason: impl Into<String>) -> Self
pub fn and_reason(self, reason: impl Into<String>) -> Self
Add a reason to this UserError.
Returns the current instance.
pub const fn message(&self) -> &String
pub const fn reasons(&self) -> &Vec<String>
pub fn reasons_mut(&mut self) -> &mut Vec<String>
pub const fn help(&self) -> &Vec<String>
pub fn help_mut(&mut self) -> &mut Vec<String>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for UserError
impl Send for UserError
impl Sync for UserError
impl Unpin for UserError
impl UnwindSafe for UserError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more