-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add error types & ctor fns
- Loading branch information
1 parent
d93940a
commit 4d3785f
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export class IllegalArityError extends Error { | ||
constructor(n: number) { | ||
super(`illegal arity: ${n}`); | ||
} | ||
} | ||
|
||
export class IllegalArgumentError extends Error { | ||
constructor(msg?: any) { | ||
super("illegal argument(s)" + (msg !== undefined ? ": " + msg : "")); | ||
} | ||
} | ||
|
||
export class IllegalStateError extends Error { | ||
constructor(msg?: any) { | ||
super("illegal state" + (msg !== undefined ? ": " + msg : "")); | ||
} | ||
} | ||
|
||
export class UnsupportedOperationError extends Error { | ||
constructor(msg?: any) { | ||
super("unsupported operation" + (msg !== undefined ? ": " + msg : "")); | ||
} | ||
} | ||
|
||
export function illegalArity(n) { | ||
throw new IllegalArityError(n); | ||
} | ||
|
||
export function illegalArgs(msg?: any) { | ||
throw new IllegalArgumentError(msg); | ||
} | ||
|
||
export function illegalState(msg?: any) { | ||
throw new IllegalArgumentError(msg); | ||
} | ||
|
||
export function unsupported(msg?: any) { | ||
throw new UnsupportedOperationError(msg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters