[]previous and next page

ShadowError

The error class of every diagnostic the runtime throws, carrying a stable code next to the message.

The error class of every diagnostic the runtime throws, carrying a stable code next to the message. Match on code rather than the message: the message is the full text in development builds and only SHADOW_<CODE> in production builds. Throw it from a custom primitive to report a core diagnostic the same way the built-in hooks do.

Import#

ts
import { ShadowError } from "@shadow-js/core/extend";

Signature#

ts
class ShadowError extends Error

Members#

Name Type Description
code readonly code: MessageCode The diagnostic code, a key of MESSAGES; the same in development and production builds.

Examples#

ts
import { ShadowError } from "@shadow-js/core/extend";

function isCycle(error: unknown): boolean {
  return error instanceof ShadowError && error.code === "CYCLE_DETECTED";
}