Documentation / @einvoice-ts/core / DocumentKindError
Class: DocumentKindError ​
Defined in: packages/core/src/errors.ts:160
A UBL document of the wrong kind was passed to a kind-specific entry point.
Thrown for example by parseInvoice() when the root element is a CreditNote, and by validate() when a document's kind is neither. Kinds are spelled as the kind discriminant spells them, Invoice and CreditNote.
Example ​
import { DocumentKindError } from '@einvoice-ts/core';
throw new DocumentKindError({ actual: 'CreditNote', expected: 'Invoice' });Extends ​
Constructors ​
Constructor ​
new DocumentKindError(
kinds,options?):DocumentKindError
Defined in: packages/core/src/errors.ts:180
Creates a document kind error.
Parameters ​
kinds ​
The document kinds involved in the mismatch.
actual ​
string
The document kind that was found.
expected ​
string
The document kind the caller asked for.
options? ​
ErrorOptions
Standard error options, in particular cause.
Returns ​
DocumentKindError
Overrides ​
Properties ​
actual ​
readonlyactual:string
Defined in: packages/core/src/errors.ts:165
The document kind that was found, for example CreditNote, or the phrase no kind when the document has none.
cause? ​
optionalcause?:unknown
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from ​
code ​
readonlycode:"EINV-DOCUMENT-KIND"
Defined in: packages/core/src/errors.ts:167
Stable, machine-readable identifier of the failure.
Overrides ​
expected ​
readonlyexpected:string
Defined in: packages/core/src/errors.ts:170
The document kind the caller asked for, for example Invoice.
message ​
message:
string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from ​
name ​
name:
string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from ​
stack? ​
optionalstack?:string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076