diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-05-01 00:40:10 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 10:40:10 -0400 |
commit | 81c75332fbf2635f5275cc85053dc244f211471d (patch) | |
tree | b0142c4dddf6f2ef2d6c48c0470e5bdfe822b499 /cli/js/util.ts | |
parent | 84d687e958ab93afb161def4a8ab47f8994307c9 (diff) |
feat: Add WritableStreams (and enable ReadableStreams piping) (#4980)
Diffstat (limited to 'cli/js/util.ts')
-rw-r--r-- | cli/js/util.ts | 12 |
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); } } |