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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
error |
unknown |
name |
string |
Returns
Section titled “Returns”error is Error
Example
Section titled “Example”if (isNamed(err, "NotFoundError")) return error(404, err.message, { code: "NOT_FOUND" });