[−][src]Struct user_error::UserFacingError
The eponymous struct.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .helptext("Make sure foo.txt exists");
Methods
impl UserFacingError<Start>[src]
pub fn new(s: &str) -> UserFacingError<Start>[src]
This is how users create a new User Facing Error. The value passed to new() will be used as an error summary. Error summaries are displayed first, prefixed by 'Error: '.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open");
pub fn print(&self)[src]
Prints the error
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open"); err.print();
pub fn print_and_exit(&self) -> ![src]
Prints the error and then exits the program
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open"); err.print_and_exit();
pub fn reason(self, r: &str) -> UserFacingError<Reason>[src]
Add a reason to the UserFacingError. Reasons are displayed in a bulleted list below the summary.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .reason("Directory cannot be entered");
pub fn helptext(self, h: &str) -> UserFacingError<HelpText>[src]
Add help text to the error. Help text is displayed last, in a muted fashion. Once you add help text you cannot add additional reasons.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .helptext("Check if the file exists.");
This will not compile
let err = UserFacingError::new("File failed to open") .helptext("Check if the file exists.") .reason("File not found");
impl UserFacingError<HelpText>[src]
pub fn print(&self)[src]
Prints the error
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .helptext("Check that it exists"); err.print();
pub fn print_and_exit(&self) -> ![src]
Prints the error and then exits the program
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .helptext("Check that it exists"); err.print_and_exit();
impl UserFacingError<Reason>[src]
pub fn from(error: &dyn Error) -> Self[src]
Allows the creation of a UserFacingError from a Error. Checks the source() of the error and will list underlying errors as reasons for the error. You may add additional reasons and helptext.
Example
use user_error::UserFacingError; let ioe = std::io::Error::new(std::io::ErrorKind::Other, "Error"); let ufe = UserFacingError::from(&ioe); let ioe = std::io::Error::new(std::io::ErrorKind::Other, "Error"); let ufe = ufe.reason("No good reason");
pub fn print(&self)[src]
Prints the error
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found"); err.print();
pub fn print_and_exit(&self) -> ![src]
Prints the error and then exits the program
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found"); err.print_and_exit();
pub fn reason(self, r: &str) -> Self[src]
Add a reason to the UserFacingError. Reasons are displayed in a bulleted list below the summary.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .reason("Directory cannot be entered");
pub fn helptext(self, h: &str) -> UserFacingError<ReasonsAndHelp>[src]
Add help text to the error. Help text is displayed last, in a muted fashion. Once you add help text you cannot add additional reasons.
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .helptext("Check if the file exists.");
This will not compile
let err = UserFacingError::new("File failed to open") .helptext("Check if the file exists.") .reason("File not found");
impl UserFacingError<ReasonsAndHelp>[src]
pub fn print(&self)[src]
Prints the error
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .helptext("Make sure the file exists"); err.print();
pub fn print_and_exit(&self) -> ![src]
Prints the error and then exits the program
Example
use user_error::UserFacingError; let err = UserFacingError::new("File failed to open") .reason("File not found") .helptext("Make sure the file exists"); err.print_and_exit();
Trait Implementations
impl<S: Debug + UFEState> Debug for UserFacingError<S>[src]
impl Display for UserFacingError<Start>[src]
impl Display for UserFacingError<HelpText>[src]
impl Display for UserFacingError<Reason>[src]
impl Display for UserFacingError<ReasonsAndHelp>[src]
impl Error for UserFacingError<Start>[src]
fn source(&self) -> Option<&(dyn Error + 'static)>[src]
fn description(&self) -> &str1.0.0[src]
fn cause(&self) -> Option<&dyn Error>1.0.0[src]
fn backtrace(&self) -> Option<&Backtrace>[src]
impl Error for UserFacingError<HelpText>[src]
fn source(&self) -> Option<&(dyn Error + 'static)>[src]
fn description(&self) -> &str1.0.0[src]
fn cause(&self) -> Option<&dyn Error>1.0.0[src]
fn backtrace(&self) -> Option<&Backtrace>[src]
impl Error for UserFacingError<Reason>[src]
fn source(&self) -> Option<&(dyn Error + 'static)>[src]
fn description(&self) -> &str1.0.0[src]
fn cause(&self) -> Option<&dyn Error>1.0.0[src]
fn backtrace(&self) -> Option<&Backtrace>[src]
impl Error for UserFacingError<ReasonsAndHelp>[src]
Auto Trait Implementations
impl<S> Send for UserFacingError<S> where
S: Send,
S: Send,
impl<S> Sync for UserFacingError<S> where
S: Sync,
S: Sync,
impl<S> Unpin for UserFacingError<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for UserFacingError<S> where
S: UnwindSafe,
S: UnwindSafe,
impl<S> RefUnwindSafe for UserFacingError<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,