Class: NubbinError
Defined in: packages/core/src/NubbinError.ts:33
Every refusal Nubbin throws, from any package, carrying its causes as data rather than only as
prose. One catch and one instanceof hold the whole surface.
It extends Error, so a handler that only ever read .message keeps working. message
summarises every cause: one issue reads as itself, several read as a count and a line each.
Example
import { NubbinError, NubbinIssueCode, compile } from "@nubbin/core";
try {
const { artifact } = compile(version, catalog, registry, "/pricing");
await store.write(artifact);
} catch (error) {
if (!(error instanceof NubbinError)) throw error;
if (error.code === NubbinIssueCode.InvalidRoute) {
return rejectRoute(error.message);
}
for (const issue of error.issues) {
editor.mark(issue.at, issue.path, issue.message);
}
}
Extends
Error
Constructors
Constructor
new NubbinError(
issues):NubbinError
Defined in: packages/core/src/NubbinError.ts:52
Parameters
issues
readonly NubbinIssue[]
The causes, first one first. code is taken from issues[0] and message
is a summary of all of them.
Returns
NubbinError
Throws
A plain Error, not a NubbinError, when issues is empty — a refusal
with no cause names nothing.
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:NubbinIssueCode
Defined in: packages/core/src/NubbinError.ts:39
The first issue's code, so the common case reads as
error.code === NubbinIssueCode.UnknownProp with no array to index and no string to typo.
Every refusal but compile's carries exactly one issue; read issues for the rest.
issues
readonlyissues: readonlyNubbinIssue[]
Defined in: packages/core/src/NubbinError.ts:44
Every cause, in the order they were found, and never empty. This is what a log, a tracker or
an editing surface serializes — each issue carries its own code, at and path.
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