[−][src]Struct user_error::UserFacingError
The eponymous struct. You can create a new one from using user_error::UserFacingError::new() however I recommend you use your own error types and have them implement UFE instead of using UserFacingError directly. This is more of an example type, or a way to construct a pretty messages without implementing your own error type.
Implementations
impl UserFacingError
[src]
pub fn new<S: Into<String>>(summary: S) -> UserFacingError
[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
let err = UserFacingError::new("File failed to open");
pub fn update<S: Into<String>>(&mut self, summary: S)
[src]
Replace the error summary.
Example
let mut err = UserFacingError::new("File failed to open"); err.update("Failed Task");
pub fn push<S: Into<String>>(&mut self, new_summary: S)
[src]
Replace the error summary and add the previous error summary to the list of reasons
Example
let mut err = UserFacingError::new("File failed to open"); err.push("Failed Task");
pub fn reason<S: Into<String>>(self, reason: S) -> UserFacingError
[src]
Add a reason to the UserFacingError. Reasons are displayed in a bulleted list below the summary, in the reverse order they were added.
Example
let err = UserFacingError::new("File failed to open") .reason("File not found") .reason("Directory cannot be entered");
pub fn clear_reasons(&mut self)
[src]
Clears all reasons from a UserFacingError.
Example
let mut err = UserFacingError::new("File failed to open") .reason("File not found") .reason("Directory cannot be entered"); err.clear_reasons();
pub fn help<S: Into<String>>(self, helptext: S) -> UserFacingError
[src]
Add help text to the error. Help text is displayed last, in a muted fashion.
Example
let err = UserFacingError::new("File failed to open") .reason("File not found") .help("Check if the file exists.");
pub fn clear_helptext(&mut self)
[src]
Clears all the help text from a UserFacingError.
Example
let mut err = UserFacingError::new("File failed to open") .reason("File not found") .reason("Directory cannot be entered") .help("Check if the file exists."); err.clear_helptext();
Trait Implementations
impl Debug for UserFacingError
[src]
impl Display for UserFacingError
[src]
impl Error for UserFacingError
[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<'_> From<&'_ (dyn Error + '_)> for UserFacingError
[src]
Allows you to create UserFacingErrors From std Errors. You should really just implement UFE for your error type, but if you wanted to convert before quitting so you could add help text of something you can use this.
fn from(error: &dyn Error) -> UserFacingError
[src]
impl From<Box<dyn Error + 'static>> for UserFacingError
[src]
Allows you to create UserFacingErrors From std Errors. You should really just implement UFE for your error type, but if you wanted to convert before quitting so you could add help text of something you can use this.
fn from(error: Box<dyn Error>) -> UserFacingError
[src]
impl From<Error> for UserFacingError
[src]
Allows you to create UserFacingErrors From std::io::Error for convenience You should really just implement UFE for your error type, but if you wanted to convert before quitting so you could add help text of something you can use this.
fn from(error: Error) -> UserFacingError
[src]
impl<T: Debug> From<Result<T, Box<dyn Error + 'static>>> for UserFacingError
[src]
Allows you to create UserFacingErrors From std Errors wrapped in a Result You should really just implement UFE for your error type, but if you wanted to convert before quitting so you could add help text of something you can use this.
impl UFE for UserFacingError
[src]
Auto Trait Implementations
impl !RefUnwindSafe for UserFacingError
impl !Send for UserFacingError
impl !Sync for UserFacingError
impl Unpin for UserFacingError
impl !UnwindSafe for UserFacingError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> 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 = Infallible
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>,