1
0
Fork 0
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:
Oliver Medhurst 2024-06-03 11:01:43 +01:00 committed by GitHub
parent b1f776adef
commit 13924fdb1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);