AssertionError

import { AssertionError } from "jsr:@ende/assert";

class

class AssertionError extends Error

Error thrown when an assertion fails.

Example: Usage

import { AssertionError } from "@ende/assert";

try {
  throw new AssertionError("foo", { cause: "bar" });
} catch (error) {
  if (error instanceof AssertionError) {
    error.message === "foo"; // true
    error.cause === "bar"; // true
  }
}

Constructors

constructor

new AssertionError(message: string, options?: ErrorOptions)

Constructs a new instance.

message: string

The error message.

options?: ErrorOptions

Additional options. This argument is still unstable. It may change in the future release.

Source