Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { Io { path: PathBuf, source: Error, }, Bundle { message: String, }, Checksum { path: String, expected: String, actual: String, }, NotXml { line: u32, column: u32, message: String, }, Unsupported { message: String, }, Limit { limit: LimitExceeded, message: String, }, OptionOutOfRange { option: &'static str, value: u32, max: u32, }, Transform { stylesheet: String, code: String, line: Option<u32>, message: String, }, Internal { message: String, }, NotCached { name: String, dir: PathBuf, }, Fetch { message: String, }, Pdf(Error), }
Expand description

Why a rule set could not be loaded, or a document could not be validated.

Validity problems of a document (schema errors, failed asserts) are not errors: they are in the Report. An error means that no complete verdict could be given.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io

A file could not be read.

Fields

§path: PathBuf

The file.

§source: Error

The cause.

§

Bundle

The bundle is not usable: a manifest that does not follow the format, a missing file, an unknown schema name, a stylesheet that is not well-formed XSLT, or one whose result is not an SVRL report.

Fields

§message: String

What is wrong, naming the file and line when known.

§

Checksum

A file of the bundle does not have the SHA-256 its manifest records.

Fields

§path: String

The file, relative to the bundle.

§expected: String

The SHA-256 the manifest records (lower-case hexadecimal).

§actual: String

The SHA-256 of the file.

§

NotXml

The document is not well-formed XML (or not namespace-well-formed, or with bytes that are not characters of its encoding, or first bytes and an XML declaration that name different encodings).

Fields

§line: u32

1-based line.

§column: u32

1-based column.

§message: String

The parser’s message.

§

Unsupported

The document or a rule-set artefact needs a construct that this engine does not implement (an encoding the validator does not read, a document type declaration, an XSLT or XML Schema construct outside the supported subset). Refused rather than answered differently from the reference engine.

Fields

§message: String

What is not supported, and where.

§

Limit

The document exceeds a limit that keeps its validation within a bounded call stack: an element nested deeper than ValidateOptions::max_depth (LimitExceeded::Depth), in the document or in a document a stylesheet loads with document(); or a stylesheet invoking templates and functions one inside another beyond the nesting that maximum allows (LimitExceeded::Nesting). Refused rather than risking a stack overflow, which would abort the process.

Fields

§limit: LimitExceeded

The limit exceeded, with its value and, for a depth, the line and column of the element.

§message: String

Where: the document, or the stylesheet (by its name in the bundle) and the line of its instruction.

§

OptionOutOfRange

An option of the validation beyond what this target allows: on WebAssembly, a ValidateOptions::max_depth above WASM_MAX_DEPTH or a ValidateOptions::max_stack above WASM_MAX_STACK, for which the native stack of the JavaScript engines has no room. Never on other targets.

Fields

§option: &'static str

The option: max_depth or max_stack.

§value: u32

The value asked for.

§max: u32

The largest value allowed.

§

Transform

A stylesheet of the rule set raised a dynamic error on the document (the reference engine fails on it as well).

Fields

§stylesheet: String

The stylesheet, by its name in the bundle.

§code: String

The XPath or XSLT error code (FORG0001, …).

§line: Option<u32>

The line of the stylesheet instruction, when known.

§message: String

The explanation.

§

Internal

A bug of this engine: a result it cannot read back.

Fields

§message: String

What went wrong.

§

NotCached

A fetched rule set (fetched_rule_sets) that is not in the cache: it must be fetched first (RuleSetCache::fetch, feature fetch; einvoice-validate rules fetch NAME). Nothing is downloaded without being asked.

Fields

§name: String

The rule set.

§dir: PathBuf

The cache directory.

§

Fetch

A rule set could not be fetched: a download failed or did not have its pinned digest, an archive is not as published, or its bundle could not be built (no Java for the Schematron compiler of Peppol BIS Billing, …).

Fields

§message: String

What went wrong, naming the URL or file concerned.

§

Pdf(Error)

No invoice XML could be extracted from a PDF file (crate::pdf::extract): its kind is ErrorKind::Unsupported for an encrypted file, a PDF feature outside the subset read or a limit exceeded, and ErrorKind::Io otherwise (not a PDF, a malformed file, no embedded file with an invoice name or several, XMP metadata that is not well-formed): the file cannot be read as an e-invoice.

Implementations§

Source§

impl Error

Source

pub const fn kind(&self) -> ErrorKind

The kind of the error.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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> 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> 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, !>

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.