Documentation / @facturometro/core / EInvoiceError
Class: EInvoiceError ​
Defined in: packages/core/src/errors.ts:36
Base class of every domain error this library throws.
code is a stable, machine-readable identifier that survives minification and message rewording, so callers can branch on it instead of on the message. Programming mistakes are deliberately not part of this hierarchy: calling an operation with an out-of-range precision or dividing by zero raises the standard RangeError, and passing a value of the wrong type raises the standard TypeError. Catching EInvoiceError therefore catches bad input, never a bug in the calling code.
Example ​
import { EInvoiceError } from '@facturometro/core';
try {
parseInvoice(xml);
} catch (error) {
// A domain error means the document is at fault and carries a code to branch on.
if (error instanceof EInvoiceError) console.error(error.code, error.message);
// Anything else (RangeError, TypeError) means the call itself was wrong: let it through.
else throw error;
}Extends ​
Error
Extended by ​
XmlSyntaxErrorUnsupportedDocumentErrorDocumentKindErrorInvalidDecimalErrorRulesetErrorValidationError
Constructors ​
Constructor ​
new EInvoiceError(
code,message,options?):EInvoiceError
Defined in: packages/core/src/errors.ts:47
Creates an error with a machine-readable code.
Parameters ​
code ​
string
Stable identifier of the failure, for example EINV-XML-SYNTAX.
message ​
string
Human-readable description.
options? ​
ErrorOptions
Standard error options, in particular cause.
Returns ​
EInvoiceError
Overrides ​
Error.constructor
Properties ​
cause? ​
optionalcause?:unknown
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from ​
Error.cause
code ​
readonlycode:string
Defined in: packages/core/src/errors.ts:38
Stable, machine-readable identifier of the failure.
message ​
message:
string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from ​
Error.message
name ​
name:
string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from ​
Error.name
stack? ​
optionalstack?:string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from ​
Error.stack