diff --git a/src/error/format.rs b/src/error/format.rs index 941a40d6..8df011e1 100644 --- a/src/error/format.rs +++ b/src/error/format.rs @@ -15,7 +15,7 @@ use crate::output::TAB; /// Defines how to format an error for displaying to the user pub trait ErrorFormatter: Sized { /// Stylize the error for the terminal - fn format_error(error: &crate::Error) -> StyledStr; + fn format_error(error: &crate::error::Error) -> StyledStr; } /// Report [`ErrorKind`] @@ -28,7 +28,7 @@ pub trait ErrorFormatter: Sized { pub struct KindFormatter; impl ErrorFormatter for KindFormatter { - fn format_error(error: &crate::Error) -> StyledStr { + fn format_error(error: &crate::error::Error) -> StyledStr { let mut styled = StyledStr::new(); start_error(&mut styled); if let Some(msg) = error.kind().as_str() { @@ -50,7 +50,7 @@ pub struct RawFormatter; #[cfg(feature = "error-context")] impl ErrorFormatter for RawFormatter { - fn format_error(error: &crate::Error) -> StyledStr { + fn format_error(error: &crate::error::Error) -> StyledStr { let mut styled = StyledStr::new(); start_error(&mut styled); if let Some(msg) = error.kind().as_str() { @@ -87,7 +87,7 @@ pub struct RichFormatter; #[cfg(feature = "error-context")] impl ErrorFormatter for RichFormatter { - fn format_error(error: &crate::Error) -> StyledStr { + fn format_error(error: &crate::error::Error) -> StyledStr { let mut styled = StyledStr::new(); start_error(&mut styled); @@ -119,7 +119,7 @@ fn start_error(styled: &mut StyledStr) { #[must_use] #[cfg(feature = "error-context")] -fn write_dynamic_context(error: &crate::Error, styled: &mut StyledStr) -> bool { +fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> bool { match error.kind() { ErrorKind::ArgumentConflict => { let invalid_arg = error.get(ContextKind::InvalidArg); diff --git a/src/lib.rs b/src/lib.rs index 0059ca39..81748c8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,7 +101,6 @@ pub use crate::builder::ArgAction; pub use crate::builder::Command; pub use crate::builder::ValueHint; pub use crate::builder::{Arg, ArgGroup}; -pub use crate::error::Error; pub use crate::parser::ArgMatches; #[cfg(feature = "color")] pub use crate::util::color::ColorChoice; @@ -110,6 +109,13 @@ pub use crate::util::color::ColorChoice; pub(crate) use crate::util::color::ColorChoice; pub use crate::util::Id; +/// Command Line Argument Parser Error +/// +/// See [`Command::error`] to create an error. +/// +/// [`Command::error`]: crate::Command::error +pub type Error = crate::error::Error; + pub use crate::derive::{Args, CommandFactory, FromArgMatches, Parser, Subcommand, ValueEnum}; #[cfg(feature = "derive")] diff --git a/tests/builder/error.rs b/tests/builder/error.rs index bbdfa735..dcd62c24 100644 --- a/tests/builder/error.rs +++ b/tests/builder/error.rs @@ -1,6 +1,6 @@ use super::utils; -use clap::{arg, error::ErrorKind, value_parser, Arg, Command, Error}; +use clap::{arg, error::Error, error::ErrorKind, value_parser, Arg, Command}; #[track_caller] fn assert_error(