diff options
author | Yusuke Tanaka <yusuktan@maguro.dev> | 2024-08-08 15:18:33 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-07 23:18:33 -0700 |
commit | 4e4c96bf66111c6e8ba976ed24594edf7abfcbfb (patch) | |
tree | 3fc2f08999df8726bd53578443556c4a0fec42b7 /ext/fetch/26_fetch.js | |
parent | 9d6da1036d80a29862f6bdfb51e6f51eee235c35 (diff) |
fix(ext/fetch): include URL and error details on fetch failures (#24910)
This commit improves error messages that `fetch` generates on failure.
Fixes #24835
Diffstat (limited to 'ext/fetch/26_fetch.js')
-rw-r--r-- | ext/fetch/26_fetch.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 674d99709..e2809187b 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -65,7 +65,7 @@ const REQUEST_BODY_HEADER_NAMES = [ /** * @param {number} rid - * @returns {Promise<{ status: number, statusText: string, headers: [string, string][], url: string, responseRid: number, error: string? }>} + * @returns {Promise<{ status: number, statusText: string, headers: [string, string][], url: string, responseRid: number, error: [string, string]? }>} */ function opFetchSend(rid) { return op_fetch_send(rid); @@ -177,8 +177,9 @@ async function mainFetch(req, recursive, terminator) { } } // Re-throw any body errors - if (resp.error) { - throw new TypeError("body failed", { cause: new Error(resp.error) }); + if (resp.error !== null) { + const { 0: message, 1: cause } = resp.error; + throw new TypeError(message, { cause: new Error(cause) }); } if (terminator.aborted) return abortedNetworkError(); |