2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-10 02:43:44 +00:00
|
|
|
// This module is browser compatible.
|
2023-12-06 17:13:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Error thrown when an assertion fails.
|
|
|
|
*
|
2024-05-30 02:38:16 +00:00
|
|
|
* @example Usage
|
|
|
|
* ```ts no-eval
|
2024-04-29 02:57:30 +00:00
|
|
|
* import { AssertionError } from "@std/assert/assertion-error";
|
2023-12-06 17:13:38 +00:00
|
|
|
*
|
|
|
|
* throw new AssertionError("Assertion failed");
|
|
|
|
* ```
|
|
|
|
*/
|
2023-07-13 07:04:30 +00:00
|
|
|
export class AssertionError extends Error {
|
2024-05-30 02:38:16 +00:00
|
|
|
/** Constructs a new instance.
|
|
|
|
*
|
|
|
|
* @example Usage
|
|
|
|
* ```ts no-eval
|
|
|
|
* import { AssertionError } from "@std/assert/assertion-error";
|
|
|
|
*
|
|
|
|
* throw new AssertionError("Assertion failed");
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @param message The error message.
|
|
|
|
*/
|
2023-07-13 07:04:30 +00:00
|
|
|
constructor(message: string) {
|
|
|
|
super(message);
|
2023-12-06 17:13:38 +00:00
|
|
|
this.name = "AssertionError";
|
2023-07-13 07:04:30 +00:00
|
|
|
}
|
|
|
|
}
|