Skip to main content

CargoAllowError

Struct CargoAllowError 

Source
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

Source

pub fn new(message: impl Into<String>) -> Self

Create an error with CargoAllowErrorKind::Unknown (backward compat).

Source

pub fn with_kind(kind: CargoAllowErrorKind, message: impl Into<String>) -> Self

Create an error with a structured kind.

Source

pub fn with_kind_preserving_metadata(self, kind: CargoAllowErrorKind) -> Self

Reclassify an existing error without discarding its structured metadata.

Aggregation and adapter layers should use this when the surrounding contract provides a more precise kind. Rebuilding with Self::with_kind would lose locations, diagnostics, and causes.

Source

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.

Source

pub fn with_message_prefix(self, prefix: impl AsRef<str>) -> Self

Prefix the human-readable message without discarding structured error metadata such as the kind, source location, diagnostics, or causes.

Context layers should use this instead of rebuilding an error from its rendered string. Rebuilding loses information that machine consumers and editor integrations rely on.

Source

pub fn with_message_suffix(self, suffix: impl AsRef<str>) -> Self

Append a message suffix without discarding structured error metadata.

Context layers should use this when adding remediation guidance after an existing message. Rebuilding an error from its rendered string loses metadata that machine consumers and editor integrations rely on.

Source

pub fn causes(&self) -> &[String]

Rendered cause messages in attachment order (outermost first).

Source

pub fn with_diagnostic(self, diagnostic: CargoAllowDiagnostic) -> Self

Attach one structured diagnostic detail, returning a new value.

Source

pub fn with_diagnostics( self, diagnostics: impl IntoIterator<Item = CargoAllowDiagnostic>, ) -> Self

Attach multiple structured diagnostic details, returning a new value.

Source

pub fn diagnostics(&self) -> &[CargoAllowDiagnostic]

Machine-readable details associated with this error.

Source

pub fn kind(&self) -> CargoAllowErrorKind

The structured error kind.

Source

pub fn code(&self) -> &'static str

The stable machine-readable code for this error.

Source

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.

Source

pub fn location(&self) -> Option<&CargoAllowErrorLocation>

Structured source location, when the error originated from located input such as a TOML parse.

Source

pub fn message(&self) -> &str

The human-readable message (without the cause chain).

Trait Implementations§

Source§

impl Clone for CargoAllowError

Source§

fn clone(&self) -> CargoAllowError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CargoAllowError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CargoAllowError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CargoAllowError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
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.

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.