Class AssertionError

Error thrown when an assertion fails.

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

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

Constructors

Properties

Constructors

  • Constructs a new instance.

    Parameters

    • message: string

      The error message.

    • Optionaloptions: ErrorOptions

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

    Returns AssertionError

Properties

cause?: unknown
message: string
name: string
stack?: string