[][src]Struct user_error::UserFacingError

pub struct UserFacingError { /* fields omitted */ }

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]

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.

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.

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.

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.