Skip to content

isNamed

function isNamed(error, name): error is Error;

Defined in: src/hooks/contract.ts:111

True when error is an error object whose name is name. Use it instead of instanceof to map domain errors to HTTP statuses: an error class loaded from a separate bundle (another subpath’s copy of the class, or another realm) fails instanceof but keeps its name.

Parameter Type
error unknown
name string

error is Error

if (isNamed(err, "NotFoundError")) return error(404, err.message, { code: "NOT_FOUND" });