pub struct CargoAllowError { /* private fields */ }Expand description
The unified error type for the cargo-allow workspace.
Carries a structured CargoAllowErrorKind, a human-readable message, and
an optional cause chain (rendered as a caused by: suffix in Display).
The kind() accessor lets programmatic consumers branch on error class
without string-matching.
Implementations§
Source§impl CargoAllowError
impl CargoAllowError
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
Create an error with CargoAllowErrorKind::Unknown (backward compat).
Sourcepub fn with_kind(kind: CargoAllowErrorKind, message: impl Into<String>) -> Self
pub fn with_kind(kind: CargoAllowErrorKind, message: impl Into<String>) -> Self
Create an error with a structured kind.
Sourcepub fn with_cause(self, cause: &(impl Error + ?Sized)) -> Self
pub fn with_cause(self, cause: &(impl Error + ?Sized)) -> Self
Attach a cause (underlying error) to this error, returning a new value.
The cause is rendered as a caused by: line in Display and linked for
std::error::Error::source walks.
Sourcepub fn causes(&self) -> &[String]
pub fn causes(&self) -> &[String]
Rendered cause messages in attachment order (outermost first).
Sourcepub fn with_diagnostic(self, diagnostic: CargoAllowDiagnostic) -> Self
pub fn with_diagnostic(self, diagnostic: CargoAllowDiagnostic) -> Self
Attach one structured diagnostic detail, returning a new value.
Sourcepub fn with_diagnostics(
self,
diagnostics: impl IntoIterator<Item = CargoAllowDiagnostic>,
) -> Self
pub fn with_diagnostics( self, diagnostics: impl IntoIterator<Item = CargoAllowDiagnostic>, ) -> Self
Attach multiple structured diagnostic details, returning a new value.
Sourcepub fn diagnostics(&self) -> &[CargoAllowDiagnostic]
pub fn diagnostics(&self) -> &[CargoAllowDiagnostic]
Machine-readable details associated with this error.
Sourcepub fn kind(&self) -> CargoAllowErrorKind
pub fn kind(&self) -> CargoAllowErrorKind
The structured error kind.
Sourcepub fn with_toml_span(
self,
path: Option<&Path>,
source: &str,
span: Option<Range<usize>>,
) -> Self
pub fn with_toml_span( self, path: Option<&Path>, source: &str, span: Option<Range<usize>>, ) -> Self
Attach a one-based source location derived from a TOML byte span.
TOML reports byte offsets. This conversion keeps the public error contract independent of the parser’s error-display text and reports a character column suitable for editor and CI diagnostics.
Sourcepub fn location(&self) -> Option<&CargoAllowErrorLocation>
pub fn location(&self) -> Option<&CargoAllowErrorLocation>
Structured source location, when the error originated from located input such as a TOML parse.
Trait Implementations§
Source§impl Clone for CargoAllowError
impl Clone for CargoAllowError
Source§fn clone(&self) -> CargoAllowError
fn clone(&self) -> CargoAllowError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CargoAllowError
impl Debug for CargoAllowError
Source§impl Display for CargoAllowError
impl Display for CargoAllowError
impl Eq for CargoAllowError
Source§impl Error for CargoAllowError
impl Error for CargoAllowError
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 From<Error> for CargoAllowError
Auto-convert io::Error so ? works at IO call sites without manual
map_err. The kind is CargoAllowErrorKind::Unknown; callers that want
a specific kind (e.g. Inventory) should use with_kind explicitly.
impl From<Error> for CargoAllowError
Auto-convert io::Error so ? works at IO call sites without manual
map_err. The kind is CargoAllowErrorKind::Unknown; callers that want
a specific kind (e.g. Inventory) should use with_kind explicitly.
Source§impl PartialEq for CargoAllowError
PartialEq compares kind + message only (not the cause chain), so tests
that assert_eq! on constructed errors are not sensitive to cause text.
impl PartialEq for CargoAllowError
PartialEq compares kind + message only (not the cause chain), so tests
that assert_eq! on constructed errors are not sensitive to cause text.