0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/js/errors.ts
Ryan Dahl bdc97b3976
Organize dispatch a bit (#2796)
Just some clean up reorganization around flatbuffer/minimal dispatch
code. This is prep for adding a JSON dispatcher.
2019-08-21 20:42:48 -04:00

25 lines
746 B
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { ErrorKind } from "gen/cli/msg_generated";
export { ErrorKind } from "gen/cli/msg_generated";
/** A Deno specific error. The `kind` property is set to a specific error code
* which can be used to in application logic.
*
* try {
* somethingThatMightThrow();
* } catch (e) {
* if (
* e instanceof Deno.DenoError &&
* e.kind === Deno.ErrorKind.Overflow
* ) {
* console.error("Overflow error!");
* }
* }
*
*/
export class DenoError<T extends ErrorKind> extends Error {
constructor(readonly kind: T, msg: string) {
super(msg);
this.name = ErrorKind[kind];
}
}