Skip to content

LaminaError

The one error class of @laminapdf/sdk (ADR 0026 §7). message, hint and didYouMean never hold document text (ADR 0026 §4); that goes in data, marked untrusted on the code’s page at docsUrl.

try {
Document.open(bytes, { password: "secret" });
} catch (e) {
if (isLaminaError(e, "wrong-password")) askAgain();
else throw e;
}
  • Error

C extends ErrorCode = ErrorCode

new LaminaError<C>(diagnostic, options?): LaminaError<C>

Diagnostic<C>

the ADR 0026 §1 object.

cause, when wrapping another error.

unknown

LaminaError<C>

Error.constructor

optional cause?: unknown

Error.cause


readonly code: C

The stable code (fixtures/codes.json).


readonly optional data?: Readonly<Record<string, unknown>>

Code-specific fields, documented on the code’s page (the only place document text appears).


readonly optional didYouMean?: readonly string[]

For usage errors: the closest known names (lamina’s own vocabulary).


readonly docsUrl: string

The code’s page.


readonly optional hint?: string

One actionable sentence for this code.


readonly kind: ErrorKind

What the caller can do about it.


readonly optional location?: Location

Where in the input or the document.


message: string

Error.message


readonly name: "LaminaError" = "LaminaError"

Error.name


optional stack?: string

Error.stack

get ranges(): readonly object[] | undefined

For data-pending: the byte ranges a range document needs fetched before the call can succeed (data.ranges); undefined for other codes. Document.ensure fetches them.

readonly object[] | undefined

toJSON(): Diagnostic<C>

The ADR 0026 §1 object (for logs, workers and --json output); optional fields omitted.

Diagnostic<C>