Skip to content

Commit

Permalink
Check for Error.captureStackTrace before using it
Browse files Browse the repository at this point in the history
Error.captureStackTrace is a V8-ism so we should check if it exists
before trying to use it or else it will fail in non-Chromium browsers.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types

Fixes #447.
  • Loading branch information
birtles committed Oct 3, 2019
1 parent df2465c commit 22f1ee0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/fetch-handler.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class AbortError extends Error {
this.message = 'The operation was aborted.';

// Do not include this class in the stacktrace
Error.captureStackTrace(this, this.constructor);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}

Expand Down

0 comments on commit 22f1ee0

Please sign in to comment.