mirror of
https://github.com/denoland/std.git
synced 2024-11-21 12:40:03 +00:00
0b2497f16e
* fix: update codebase to work with Deno RC * work * fix * fix * fix * fixes * work * update * fixes * fix * revert
32 lines
842 B
TypeScript
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";
|
|
}
|
|
}
|