#[non_exhaustive]pub struct LedgerError {
pub severity: ErrorSeverity,
pub code: String,
pub message: String,
pub location: Option<ErrorLocation>,
pub source_span: Option<(usize, usize)>,
pub file_id: Option<u16>,
pub phase: String,
}Expand description
Unified error type for ledger processing.
This encompasses all error types that can occur during loading, booking, plugin execution, and validation.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.severity: ErrorSeverityError severity.
code: StringError code (e.g., “E0001”, “W8002”).
message: StringHuman-readable error message.
location: Option<ErrorLocation>Source location, if available.
source_span: Option<(usize, usize)>Byte span (inclusive start, exclusive end) in the source file,
used by rich renderers (e.g. miette) to draw a snippet around
the offending directive. Consumers that only need file:line:col
should use location; those that want to show the surrounding
source text want this.
file_id: Option<u16>Source file ID — index into the ledger’s SourceMap. Used
alongside source_span for snippet rendering.
phase: StringProcessing phase that produced this error: “parse”, “validate”, or “plugin”.
Implementations§
Source§impl LedgerError
impl LedgerError
Sourcepub fn error(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn error(code: impl Into<String>, message: impl Into<String>) -> Self
Create a new error with the given phase.
Sourcepub fn warning(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn warning(code: impl Into<String>, message: impl Into<String>) -> Self
Create a new warning.
Sourcepub const fn with_source_span(self, span: (usize, usize), file_id: u16) -> Self
pub const fn with_source_span(self, span: (usize, usize), file_id: u16) -> Self
Attach a source span and file ID so rich renderers can draw a snippet.
Sourcepub fn with_phase(self, phase: impl Into<String>) -> Self
pub fn with_phase(self, phase: impl Into<String>) -> Self
Set the processing phase for this error.
Sourcepub fn with_location(self, location: ErrorLocation) -> Self
pub fn with_location(self, location: ErrorLocation) -> Self
Add a location to this error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LedgerError
impl RefUnwindSafe for LedgerError
impl Send for LedgerError
impl Sync for LedgerError
impl Unpin for LedgerError
impl UnsafeUnpin for LedgerError
impl UnwindSafe for LedgerError
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.