Skip to content

Commit

Permalink
fix: add check for using Error.captureStackTrace (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Pull <matt@mattcorp.com>
  • Loading branch information
matthewpull and matthewpull committed Nov 10, 2021
1 parent 7e1b54d commit 0c55e1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export function createFetch ({ fetch }: CreateFetchOptions): $Fetch {

// Throw normalized error
const err = createFetchError(request, error, response)
Error.captureStackTrace(err, $fetchRaw)
// Only available on V8 based runtimes (https://v8.dev/docs/stack-trace-api)
if (Error.captureStackTrace) {
Error.captureStackTrace(err, $fetchRaw)
}
throw err
}

Expand Down

0 comments on commit 0c55e1e

Please sign in to comment.