std/assert/assertion_error.ts
Yoshiya Hinosawa 47c38498eb
docs(assert): improve docs (#4876)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-05-30 11:38:16 +09:00

31 lines
721 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 no-eval
* import { AssertionError } from "@std/assert/assertion-error";
*
* throw new AssertionError("Assertion failed");
* ```
*/
export class AssertionError extends Error {
/** 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.
*/
constructor(message: string) {
super(message);
this.name = "AssertionError";
}
}