pub struct Error {
pub message: String,
pub code: Option<String>,
pub phase: Option<String>,
pub hint: Option<String>,
pub file: Option<String>,
pub line: Option<u32>,
pub column: Option<u32>,
pub end_line: Option<u32>,
pub end_column: Option<u32>,
pub severity: Severity,
}Expand description
An error with source location.
Renamed to BeancountError on the TS side to avoid shadowing
the JS-builtin Error type. The Rust struct keeps the shorter
Error name for internal use; the rename is applied via
#[ts(rename = ...)] so consumers see a non-shadowing name.
Fields§
§message: StringError message.
code: Option<String>Stable error code (e.g. "P0001" for a parse error, "E3001" for a
validation error). null for errors without a code (generic processing
/ query / plugin errors). Lets consumers branch on error type instead of
matching on message text.
phase: Option<String>Processing phase that produced the error: typically "parse",
"validate", "plugin", or "lint". null when not
attributable to a phase. The set is open (the loader phase is a free
string), so the TS type is a union of the known values plus string —
consumers get autocomplete on the common phases without rejecting others.
hint: Option<String>Actionable hint for fixing the error, when one is available. null
otherwise.
file: Option<String>Source file the error came from (multi-file ledgers). null for the
single-source WASM entry points (parse, check, …).
line: Option<u32>Start line (1-based). null when the error has no source
location (e.g. validation errors not tied to a span). Field is
always present on the wire (no skip_serializing_if); see the
struct-level schemars(extend) for the required-and-nullable
rationale. range(min = 1) enforces the 1-based documented
contract on the JSON Schema side (schemars defaults to
minimum: 0 for u32).
column: Option<u32>Start column (1-based). null when the error has no source
location. See line above for range rationale.
end_line: Option<u32>End line (1-based) of the error span. null when no span. See line.
end_column: Option<u32>End column (1-based) of the error span. null when no span. See line.
severity: SeverityError severity.
Implementations§
Source§impl Error
impl Error
Sourcepub fn with_line(message: impl Into<String>, line: u32) -> Self
pub fn with_line(message: impl Into<String>, line: u32) -> Self
Create an error with a (start) line number.
Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Builder: set the stable error code (e.g. "P0001", "E3001").
Sourcepub fn with_phase(self, phase: impl Into<String>) -> Self
pub fn with_phase(self, phase: impl Into<String>) -> Self
Builder: set the processing phase ("parse", "validate", …).
Trait Implementations§
Source§impl Archive for Error
impl Archive for Error
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedError
type Archived = ArchivedError
Source§type Resolver = ErrorResolver
type Resolver = ErrorResolver
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<Error, __D> for Archived<Error>where
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
Option<String>: Archive,
<Option<String> as Archive>::Archived: Deserialize<Option<String>, __D>,
Option<u32>: Archive,
<Option<u32> as Archive>::Archived: Deserialize<Option<u32>, __D>,
Severity: Archive,
<Severity as Archive>::Archived: Deserialize<Severity, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Error, __D> for Archived<Error>where
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
Option<String>: Archive,
<Option<String> as Archive>::Archived: Deserialize<Option<String>, __D>,
Option<u32>: Archive,
<Option<u32> as Archive>::Archived: Deserialize<Option<u32>, __D>,
Severity: Archive,
<Severity as Archive>::Archived: Deserialize<Severity, __D>,
Source§impl From<LedgerError> for Error
impl From<LedgerError> for Error
Source§fn from(e: LedgerError) -> Self
fn from(e: LedgerError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.