pub struct Error { /* private fields */ }Expand description
A parse failure.
Implementations§
Source§impl Error
impl Error
Sourcepub fn unknown_flag(offset: usize, token: impl Into<String>) -> Self
pub fn unknown_flag(offset: usize, token: impl Into<String>) -> Self
A flag-like word, at offset, that matched nothing.
Sourcepub fn unexpected_arg(offset: usize, token: impl Into<String>) -> Self
pub fn unexpected_arg(offset: usize, token: impl Into<String>) -> Self
A word, at offset, that nothing could hold.
Sourcepub fn missing_value(offset: usize, flag: impl Into<String>) -> Self
pub fn missing_value(offset: usize, flag: impl Into<String>) -> Self
flag, at offset, needed a value and did not get one.
Sourcepub fn unexpected_value(
offset: usize,
flag: impl Into<String>,
value: &[u8],
) -> Self
pub fn unexpected_value( offset: usize, flag: impl Into<String>, value: &[u8], ) -> Self
flag, at offset, takes no value but was given value.
Sourcepub fn missing_required(offset: usize, flag: impl Into<String>) -> Self
pub fn missing_required(offset: usize, flag: impl Into<String>) -> Self
The required flag never appeared. The offset is the end of the line.
Sourcepub fn missing_argument(offset: usize, name: impl Into<String>) -> Self
pub fn missing_argument(offset: usize, name: impl Into<String>) -> Self
The required positional name was never filled. The offset is the end of the line.
Sourcepub fn required_by(offset: usize, target: impl Into<String>, name: &str) -> Self
pub fn required_by(offset: usize, target: impl Into<String>, name: &str) -> Self
name requires target, which has no value. The offset is the end of the line.
Sourcepub fn conflict(offset: usize, name: impl Into<String>, other: &str) -> Self
pub fn conflict(offset: usize, name: impl Into<String>, other: &str) -> Self
name and other exclude each other and were both given.
Sourcepub fn missing_one_of(
offset: usize,
group: impl Into<String>,
members: &[&str],
) -> Self
pub fn missing_one_of( offset: usize, group: impl Into<String>, members: &[&str], ) -> Self
The required group group had none of members.
Sourcepub fn requires_double_dash(offset: usize, name: impl Into<String>) -> Self
pub fn requires_double_dash(offset: usize, name: impl Into<String>) -> Self
The word at offset reached name, which only takes words after --.
Sourcepub fn help(command: &'static Command, long: bool) -> Self
pub fn help(command: &'static Command, long: bool) -> Self
-h (long == false) or --help for command.
Sourcepub fn bare_help(command: &'static Command) -> Self
pub fn bare_help(command: &'static Command) -> Self
A bare invocation of an arg_required_else_help command.
Sourcepub fn within(self, name: &'static str) -> Self
pub fn within(self, name: &'static str) -> Self
Record that this came from within subcommand name, for the usage line
and for what Error::suggested looks among.
Sourcepub fn suggested(self, root: &'static Command) -> Self
pub fn suggested(self, root: &'static Command) -> Self
Look among what root and the subcommand it failed in take for what
an unknown flag or word was probably meant to be: Error::similar
then has it. Args::parse_words and what
is built on it do this; a parse through
Args::parse_argv does not.
Sourcepub fn similar(&self) -> Option<&str>
pub fn similar(&self) -> Option<&str>
What the flag, subcommand or value at fault was probably meant to be, when something close to it is accepted there.
Sourcepub fn render_help(&self, program: &str) -> Option<String>
pub fn render_help(&self, program: &str) -> Option<String>
The help to show for a ErrorKind::HelpRequested, program leading
the usage line; plain, see Error::render_help_styled for color.
Sourcepub fn version_text(&self, program: &str) -> Option<String>
pub fn version_text(&self, program: &str) -> Option<String>
program version for a ErrorKind::VersionRequested.
Sourcepub fn is_bare_help(&self) -> bool
pub fn is_bare_help(&self) -> bool
Help for a bare invocation, which is an error to report rather than an answer.
Sourcepub fn missing_subcommand(offset: usize) -> Self
pub fn missing_subcommand(offset: usize) -> Self
A required subcommand was not given. The offset is the end of the line.
Sourcepub fn invalid_value(
offset: usize,
flag: impl Into<String>,
value: &[u8],
cause: impl Into<BoxError>,
) -> Self
pub fn invalid_value( offset: usize, flag: impl Into<String>, value: &[u8], cause: impl Into<BoxError>, ) -> Self
value given to flag at offset was rejected by its type.
Sourcepub fn value(&self) -> Option<&str>
pub fn value(&self) -> Option<&str>
The offending value, for ErrorKind::UnexpectedValue and ErrorKind::InvalidValue.
Source§impl Error
impl Error
Sourcepub fn message(&self, style: Style) -> String
pub fn message(&self, style: Style) -> String
What went wrong, as Display says it, with what was
typed painted in the palette’s invalid and what is missing in valid.
Sourcepub fn tip(&self, style: Style) -> Option<String>
pub fn tip(&self, style: Style) -> Option<String>
tip: a similar flag exists: … for an error that has Error::similar,
painted as what is missing is.
Sourcepub fn render(&self, style: Style) -> String
pub fn render(&self, style: Style) -> String
The whole report for an error that is not help or version:
error: …, a tip when something close was accepted, and a pointer to
--help.
Sourcepub fn render_help_styled(&self, program: &str, style: Style) -> Option<String>
pub fn render_help_styled(&self, program: &str, style: Style) -> Option<String>
Error::render_help, painted with style.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<'i, E> FromExternalError<Argv<'i>, E> for Error
Lets try_map report a conversion failure. It backtracks, like any winnow
error; the flag parsers in crate::combinator convert values themselves
and commit, so their errors can name the flag.
impl<'i, E> FromExternalError<Argv<'i>, E> for Error
Lets try_map report a conversion failure. It backtracks, like any winnow
error; the flag parsers in crate::combinator convert values themselves
and commit, so their errors can name the flag.
Source§fn from_external_error(input: &Argv<'i>, e: E) -> Self
fn from_external_error(input: &Argv<'i>, e: E) -> Self
ParserError::from_input but also include an external error.Source§impl ModalError for Error
impl ModalError for Error
Source§impl<'i, const N: usize> Parser<Argv<'i>, Arg<'i>, Error> for Named<N>
One occurrence of the flag’s name, value not yet read.
impl<'i, const N: usize> Parser<Argv<'i>, Arg<'i>, Error> for Named<N>
One occurrence of the flag’s name, value not yet read.
Source§fn parse(
&mut self,
input: I,
) -> Result<O, ParseError<I, <E as ParserError<I>>::Inner>>where
Self: Sized,
I: Stream + StreamIsPartial,
E: ParserError<I>,
<E as ParserError<I>>::Inner: ParserError<I>,
fn parse(
&mut self,
input: I,
) -> Result<O, ParseError<I, <E as ParserError<I>>::Inner>>where
Self: Sized,
I: Stream + StreamIsPartial,
E: ParserError<I>,
<E as ParserError<I>>::Inner: ParserError<I>,
Source§fn parse_iter(&mut self, input: I) -> ParseIter<'_, Self, I, O, E> ⓘwhere
Self: Sized,
I: Stream + StreamIsPartial,
E: ParserError<I>,
<E as ParserError<I>>::Inner: ParserError<I>,
fn parse_iter(&mut self, input: I) -> ParseIter<'_, Self, I, O, E> ⓘwhere
Self: Sized,
I: Stream + StreamIsPartial,
E: ParserError<I>,
<E as ParserError<I>>::Inner: ParserError<I>,
Source§fn parse_peek(&mut self, input: I) -> Result<(I, O), E>
fn parse_peek(&mut self, input: I) -> Result<(I, O), E>
Source§fn by_ref(&mut self) -> ByRef<'_, Self, I, O, E>where
Self: Sized,
fn by_ref(&mut self) -> ByRef<'_, Self, I, O, E>where
Self: Sized,
&mut Self as a parser Read moreSource§fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Source§fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
Parser Read moreSource§fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
std::convert::From Read moreSource§fn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Source§fn span(self) -> Span<Self, I, O, E>
fn span(self) -> Span<Self, I, O, E>
Source§fn with_span(self) -> WithSpan<Self, I, O, E>
fn with_span(self) -> WithSpan<Self, I, O, E>
Source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
Source§fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>where
Self: Sized,
G: FnMut(O) -> Result<O2, E2>,
I: Stream,
E: FromExternalError<I, E2> + ParserError<I>,
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>where
Self: Sized,
G: FnMut(O) -> Result<O2, E2>,
I: Stream,
E: FromExternalError<I, E2> + ParserError<I>,
Result over the output of a parser. Read moreSource§fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
Source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
Source§fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
std::str::FromStr to the output of the parser Read moreSource§fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
Source§fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
Source§fn context_with<F, C, FI>(
self,
context: F,
) -> ContextWith<Self, I, O, E, F, C, FI>where
Self: Sized,
I: Stream,
E: AddContext<I, C> + ParserError<I>,
F: Fn() -> FI + Clone,
C: Debug,
FI: Iterator<Item = C>,
fn context_with<F, C, FI>(
self,
context: F,
) -> ContextWith<Self, I, O, E, F, C, FI>where
Self: Sized,
I: Stream,
E: AddContext<I, C> + ParserError<I>,
F: Fn() -> FI + Clone,
C: Debug,
FI: Iterator<Item = C>,
Source§fn map_err<G, E2>(self, map: G) -> MapErr<Self, G, I, O, E, E2>
fn map_err<G, E2>(self, map: G) -> MapErr<Self, G, I, O, E, E2>
Source§fn complete_err(self) -> CompleteErr<Self, I, O, E>where
Self: Sized,
fn complete_err(self) -> CompleteErr<Self, I, O, E>where
Self: Sized,
Source§impl<'i> ParserError<Argv<'i>> for Error
impl<'i> ParserError<Argv<'i>> for Error
Source§fn or(self, other: Self) -> Self
fn or(self, other: Self) -> Self
Keep whichever of the two says more: a specific failure beats a bare “did not match”, and otherwise the later branch wins, as in winnow.
Source§fn from_input(input: &Argv<'i>) -> Self
fn from_input(input: &Argv<'i>) -> Self
Source§fn is_backtrack(&self) -> bool
fn is_backtrack(&self) -> bool
Source§fn into_inner(self) -> Result<Self::Inner, Self>
fn into_inner(self) -> Result<Self::Inner, Self>
Source§fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
Source§fn incomplete(input: &I, _needed: Needed) -> Self
fn incomplete(input: &I, _needed: Needed) -> Self
Source§fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
ParserError::from_input but merges it with the existing error. Read more