summaryrefslogtreecommitdiff
path: root/cli/js/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/util.ts')
-rw-r--r--cli/js/util.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/js/util.ts b/cli/js/util.ts
index 6db8ade7b..309bfcd0c 100644
--- a/cli/js/util.ts
+++ b/cli/js/util.ts
@@ -20,9 +20,17 @@ export function log(...args: unknown[]): void {
}
// @internal
-export function assert(cond: unknown, msg = "assert"): asserts cond {
+export class AssertionError extends Error {
+ constructor(msg?: string) {
+ super(msg);
+ this.name = "AssertionError";
+ }
+}
+
+// @internal
+export function assert(cond: unknown, msg = "Assertion failed."): asserts cond {
if (!cond) {
- throw Error(msg);
+ throw new AssertionError(msg);
}
}