mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(console): add missing AssertionError to js (#22358)
Previously it did not exist, so `assert` would crash the wrong way if it failed. Signed-off-by: CanadaHonk <honk@goose.icu>
This commit is contained in:
parent
b1f776adef
commit
13924fdb1b
1 changed files with 7 additions and 0 deletions
|
@ -172,6 +172,13 @@ function getStderrNoColor() {
|
|||
return noColorStderr();
|
||||
}
|
||||
|
||||
class AssertionError extends Error {
|
||||
name = "AssertionError";
|
||||
constructor(message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
function assert(cond, msg = "Assertion failed.") {
|
||||
if (!cond) {
|
||||
throw new AssertionError(msg);
|
||||
|
|
Loading…
Reference in a new issue