nc.errors
The errors node-comfort throws. They all extend NodeComfortError (itself a regular Error) and carry a stable code, so you can branch on the kind of failure without parsing messages.
const { errors } = require("@ix-xs/node-comfort");
import { default } from "@ix-xs/node-comfort/errors";try {
await nc.http.get("https://api.example.com/users/42");
} catch (error) {
if (error instanceof nc.errors.HttpError && error.status === 404) return null;
throw error;
}nc.errors.Functions
nc.errors.NodeComfortErrorproperty
NodeComfortError: typeof NodeComfortErrorBase class of every node-comfort error. name is the class name and code a stable identifier.
nc.errors.AssertionErrorproperty
AssertionError: typeof AssertionErrorThrown by nc.assert() and nc.assertType().
nc.errors.TimeoutErrorproperty
TimeoutError: typeof TimeoutErrorThrown when something takes too long: func.timeout, async.poll, HTTP requests, emitter.waitFor...
nc.errors.AbortErrorproperty
AbortError: typeof AbortErrorThrown when an operation is cancelled with an AbortSignal. Its name is "AbortError", like native abort errors, so existing checks keep working.
nc.errors.ValidationErrorproperty
ValidationError: typeof ValidationErrorThrown when data doesn't match a schema or when environment variables are invalid. issues lists every problem, not just the first one.
nc.errors.HttpErrorproperty
HttpError: typeof HttpErrorThrown by nc.http when the response status isn't 2xx (unless you pass throwHttpErrors: false), and for network failures (status 0).
nc.errors.JWTErrorproperty
JWTError: typeof JWTErrorThrown by nc.crypto.verifyJWT(). The code tells you why: ERR_JWT_MALFORMED, ERR_JWT_ALGORITHM, ERR_JWT_SIGNATURE, ERR_JWT_EXPIRED, ERR_JWT_NOT_BEFORE or ERR_JWT_CLAIM.
nc.errors.ProcessErrorproperty
ProcessError: typeof ProcessErrorThrown by nc.sys.run() and nc.sys.exec() when a command fails, is killed or times out. Its output is kept on the error.
nc.errors.SQLiteErrorproperty
SQLiteError: typeof SQLiteErrorThrown by nc.SQLite when a statement fails. Check sqliteCode to handle specific cases like a duplicate value.
Types
Import any of them in TypeScript with import type { NodeComfortErrorOptions } from "@ix-xs/node-comfort", or in JavaScript with import("@ix-xs/node-comfort").NodeComfortErrorOptions.
NodeComfortErrorOptions
Options shared by every error constructor.
| Property | Type | Description |
|---|---|---|
codeoptional | string | Machine-readable code, like "ETIMEDOUT". |
causeoptional | unknown | The error that caused this one, kept as error.cause. |
ValidationIssue
One problem found while validating data.
| Property | Type | Description |
|---|---|---|
path | (string | number)[] | Where the problem is, like ["user", "emails", 0]. Empty for the root value. |
code | string | What went wrong: "invalid_type", "too_small", "invalid_string", "custom"... |
message | string | A message you can show to users. |
expectedoptional | string | The expected type, for type errors. |
receivedoptional | string | The received type, for type errors. |