import * as fbs from "gen/msg_generated"; export { ErrorKind } from "gen/msg_generated"; // @internal export class DenoError extends Error { constructor(readonly kind: T, msg: string) { super(msg); this.name = fbs.ErrorKind[kind]; } } // @internal export function maybeThrowError(base: fbs.Base): void { const err = maybeError(base); if (err != null) { throw err; } } export function maybeError(base: fbs.Base): null | DenoError { const kind = base.errorKind(); if (kind === fbs.ErrorKind.NoError) { return null; } else { return new DenoError(kind, base.error()!); } }