summaryrefslogtreecommitdiff
path: root/js/errors.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/errors.ts')
-rw-r--r--js/errors.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/js/errors.ts b/js/errors.ts
index 11d4cd509..2d0572e6d 100644
--- a/js/errors.ts
+++ b/js/errors.ts
@@ -10,8 +10,17 @@ export class DenoError<T extends fbs.ErrorKind> extends Error {
// @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<fbs.ErrorKind> {
const kind = base.errorKind();
- if (kind !== fbs.ErrorKind.NoError) {
- throw new DenoError(kind, base.error()!);
+ if (kind === fbs.ErrorKind.NoError) {
+ return null;
+ } else {
+ return new DenoError(kind, base.error()!);
}
}