blob: 2fca10eaf95d88b2cb22c9d65d52d3696cea84dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import { deno as fbs } from "gen/msg_generated";
export class DenoError<T extends fbs.ErrorKind> extends Error {
constructor(readonly kind: T, msg: string) {
super(msg);
this.name = `deno.${fbs.ErrorKind[kind]}`;
}
}
export function maybeThrowError(base: fbs.Base): void {
const kind = base.errorKind();
if (kind !== fbs.ErrorKind.NoError) {
throw new DenoError(kind, base.error()!);
}
}
|