logo

Struct clap::Error

source · []
pub struct Error {
    pub kind: ErrorKind,
    pub info: Vec<String>,
    /* private fields */
}
Expand description

Command Line Argument Parser Error

Fields

kind: ErrorKind

The type of error

info: Vec<String>

Additional information depending on the error kind, like values and argument names. Useful when you want to render an error of your own.

Implementations

Should the message be written to stdout or not

Prints the error and exits. Depending on the error kind, this either prints to stderr and exits with a status of 1 or prints to stdout and exits with a status of 0.

Prints formatted and colored error to stdout or stderr according to its error kind

Example
use clap::App;

match App::new("App").try_get_matches() {
    Ok(matches) => {
        // do_something
    },
    Err(err) => {
        err.print().expect("Error writing Error");
        // do_something
    },
};

Create an error with a custom description.

This can be used in combination with Error::exit to exit your program with a custom error message.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.