pub struct ArgumentError { /* private fields */ }Expand description
A structured argument validation failure.
The error owns its argument path and failure kind, allowing downstream
error types to inspect or preserve it without parsing display text.
Display escapes caller-provided fields into a single-line diagnostic;
accessors and Debug continue to expose the original structured values.
§Examples
use qubit_argument::{ArgumentError, ArgumentErrorKind};
let error = ArgumentError::new("value", ArgumentErrorKind::Missing);
assert_eq!(error.to_string(), "argument 'value' is missing");#![deny(unused_must_use)]
use qubit_argument::{ArgumentError, ArgumentErrorKind};
ArgumentError::new("value", ArgumentErrorKind::Missing);Implementations§
Source§impl ArgumentError
impl ArgumentError
Sourcepub fn new(path: &str, kind: ArgumentErrorKind) -> Self
pub fn new(path: &str, kind: ArgumentErrorKind) -> Self
Creates an error from an argument path and structured failure kind.
path is copied only while constructing the error. The supplied
kind is retained unchanged.
§Parameters
path: The path identifying the argument that failed validation.kind: The structured reason for the validation failure.
§Returns
An error that owns the path and failure kind.
Sourcepub fn path(&self) -> &ArgumentPath
pub fn path(&self) -> &ArgumentPath
Returns the path of the argument that failed validation.
§Returns
The path borrowed from this error.
Sourcepub fn kind(&self) -> &ArgumentErrorKind
pub fn kind(&self) -> &ArgumentErrorKind
Sourcepub fn with_path_prefix(self, prefix: &str) -> Self
pub fn with_path_prefix(self, prefix: &str) -> Self
Sourcepub fn into_parts(self) -> (ArgumentPath, ArgumentErrorKind)
pub fn into_parts(self) -> (ArgumentPath, ArgumentErrorKind)
Consumes the error and returns its owned path and failure kind.
The first tuple element is the argument path and the second is the structured failure kind.
§Returns
The owned argument path and structured failure kind, in that order.
Trait Implementations§
Source§impl Clone for ArgumentError
impl Clone for ArgumentError
Source§impl Debug for ArgumentError
impl Debug for ArgumentError
Source§impl Display for ArgumentError
impl Display for ArgumentError
impl Eq for ArgumentError
Source§impl Error for ArgumentError
impl Error for ArgumentError
1.30.0 · 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()