Skip to content

Commit

Permalink
refactor(fetch): TypeError supports cause option
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag authored and metcoder95 committed Dec 26, 2022
1 parent 99083db commit 8f9249f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ class Request {
try {
parsedURL = new URL(input, baseUrl)
} catch (err) {
const error = new TypeError('Failed to parse URL from ' + input)
error.cause = err
throw error
throw new TypeError('Failed to parse URL from ' + input, { cause: err })
}

// 3. If parsedURL includes credentials, then throw a TypeError.
Expand Down Expand Up @@ -227,11 +225,7 @@ class Request {
try {
parsedReferrer = new URL(referrer, baseUrl)
} catch (err) {
const error = new TypeError(
`Referrer "${referrer}" is not a valid URL.`
)
error.cause = err
throw error
throw new TypeError(`Referrer "${referrer}" is not a valid URL.`, { cause: err })
}

// 3. If one of the following is true
Expand Down

0 comments on commit 8f9249f

Please sign in to comment.