std/assert/assertion_error.ts
Asher Gomez 0b2497f16e
fix: update codebase to work with Deno RC (#6018)
* fix: update codebase to work with Deno RC

* work

* fix

* fix

* fix

* fixes

* work

* update

* fixes

* fix

* revert
2024-09-20 09:29:31 +10:00

32 lines
842 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/**
* Error thrown when an assertion fails.
*
* @example Usage
* ```ts ignore
* 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
* }
* }
* ```
*/
export class AssertionError extends Error {
/** Constructs a new instance.
*
* @param message The error message.
* @param options Additional options. This argument is still unstable. It may change in the future release.
*/
constructor(message: string, options?: ErrorOptions) {
super(message, options);
this.name = "AssertionError";
}
}