From fdf83db2018d1233871a37b7404f05717ef366a2 Mon Sep 17 00:00:00 2001 From: wbamberg Date: Tue, 2 Jul 2024 17:09:00 -0700 Subject: [PATCH] Fix issue 13208: document response body access exceptions --- files/en-us/web/api/response/arraybuffer/index.md | 8 ++++++++ files/en-us/web/api/response/blob/index.md | 5 +++++ files/en-us/web/api/response/bytes/index.md | 6 +++--- files/en-us/web/api/response/formdata/index.md | 8 ++++++++ files/en-us/web/api/response/json/index.md | 7 +++++++ files/en-us/web/api/response/text/index.md | 5 +++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/response/arraybuffer/index.md b/files/en-us/web/api/response/arraybuffer/index.md index 7fac36653d7a57b..7a3e15a676e9d3f 100644 --- a/files/en-us/web/api/response/arraybuffer/index.md +++ b/files/en-us/web/api/response/arraybuffer/index.md @@ -26,6 +26,14 @@ None. A promise that resolves with an {{jsxref("ArrayBuffer")}}. +### Exceptions + +- {{jsxref("TypeError")}} + - : The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). +- {{jsxref("RangeError")}} + - : There is a problem creating the associated `ArrayBuffer`. + For example, if the data size is more than [`Number.MAX_SAFE_INTEGER`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER). + ## Examples ### Playing music diff --git a/files/en-us/web/api/response/blob/index.md b/files/en-us/web/api/response/blob/index.md index 950d89bb1f82228..90db0ea784dd626 100644 --- a/files/en-us/web/api/response/blob/index.md +++ b/files/en-us/web/api/response/blob/index.md @@ -32,6 +32,11 @@ None. A promise that resolves with a {{domxref("Blob")}}. +### Exceptions + +- {{jsxref("TypeError")}} + - : The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). + ## Examples In our [fetch request example](https://github.com/mdn/dom-examples/tree/main/fetch/fetch-request) (run [fetch request live](https://mdn.github.io/dom-examples/fetch/fetch-request/)), we diff --git a/files/en-us/web/api/response/bytes/index.md b/files/en-us/web/api/response/bytes/index.md index 4c72ce610ef2e84..d7ac5ce3d5f5d47 100644 --- a/files/en-us/web/api/response/bytes/index.md +++ b/files/en-us/web/api/response/bytes/index.md @@ -27,9 +27,9 @@ A promise that resolves with an {{jsxref("Uint8Array")}}. ### Exceptions -- `TypeError` - - : The response body has already been read from, or the associated stream is locked or has been cancelled. -- `RangeError` +- {{jsxref("TypeError")}} + - : The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). +- {{jsxref("RangeError")}} - : There is a problem creating the associated `ArrayBuffer`. For example, if the data size is more than [`Number.MAX_SAFE_INTEGER`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER). diff --git a/files/en-us/web/api/response/formdata/index.md b/files/en-us/web/api/response/formdata/index.md index 4e152f352c24635..ade36e73e9cd372 100644 --- a/files/en-us/web/api/response/formdata/index.md +++ b/files/en-us/web/api/response/formdata/index.md @@ -31,6 +31,14 @@ None. A {{jsxref("Promise")}} that resolves with a {{domxref("FormData")}} object. +### Exceptions + +- {{jsxref("TypeError")}} + - : Thrown for one of the following reasons: + - The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). + - The {{glossary("MIME")}} type of the body cannot be determined from the {{httpheader("Content-Type")}} headers included in the response. + - The body cannot be parsed as a `FormData` object. + ## Examples TBD. diff --git a/files/en-us/web/api/response/json/index.md b/files/en-us/web/api/response/json/index.md index 92562df024ca279..8d11f0f68404e1f 100644 --- a/files/en-us/web/api/response/json/index.md +++ b/files/en-us/web/api/response/json/index.md @@ -29,6 +29,13 @@ None. A {{jsxref("Promise")}} that resolves to a JavaScript object. This object could be anything that can be represented by JSON — an object, an array, a string, a number… +### Exceptions + +- {{jsxref("TypeError")}} + - : The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). +- {{jsxref("SyntaxError")}} + - : The response body cannot be parsed as JSON. + ## Examples In our [fetch JSON example](https://github.com/mdn/dom-examples/tree/main/fetch/fetch-json) (run [fetch JSON live](https://mdn.github.io/dom-examples/fetch/fetch-json/)), diff --git a/files/en-us/web/api/response/text/index.md b/files/en-us/web/api/response/text/index.md index ca4dc031e7cfa5f..bfb59e3178a09d7 100644 --- a/files/en-us/web/api/response/text/index.md +++ b/files/en-us/web/api/response/text/index.md @@ -26,6 +26,11 @@ None. A Promise that resolves with a {{jsxref("String")}}. +### Exceptions + +- {{jsxref("TypeError")}} + - : The response body is [disturbed or locked](/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams). + ## Examples In our [fetch text example](https://github.com/mdn/dom-examples/tree/main/fetch/fetch-text) (run [fetch text live](https://mdn.github.io/dom-examples/fetch/fetch-text/)), we have an {{htmlelement("article")}} element and three links (stored in the `myLinks` array.)