Errors#

Error class#

DsError#

constructor(statusCode: number, detail?: string, options?: ErrorOptions);

A failing libds call: the form of a non-OK ds_result_t, and class DsError extends Error.

Its name is "DsError". Its message is ds status <status>: <detail>, without the detail where there is none.

A TypeError or RangeError these pages name carries no status.

try {
  engine.pump();
} catch (err) {
  if (err instanceof ds.DsError) console.log(err.status, err.detail);
}

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

DsError.status#

status: number;

The status number, as the error catalogue lists it.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

DsError.detail#

detail: string;

libds’s detail string, copied when the error is made, and "" where there is none.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)

DsError.cause#

cause

The exception of the host function behind the failure, where there is one: a writeThrough handler’s, or a recording sink’s.

(Source: bindings/js/lib/bind.js, bindings/js/src/ds.c)

Status codes#

status#

export { status };

The namespace of status constants: DS_OK and each DS_ERR_* of the error catalogue, each as its number, with STATUS.

Both entry points that open libds export it, and Api.status is the same namespace. The ./status entry point exports the same names, and loads no libds.

(Source: bindings/js/types/bind.d.ts, bindings/js/types/status.d.ts, bindings/js/lib/status.js, bindings/js/package.json)

STATUS#

export const STATUS: Readonly<{ DS_OK: 0; ... }>;

A frozen object of every status, name to number.

(Source: bindings/js/types/status.d.ts, bindings/js/lib/status.js)