Skip to content

Commit

Permalink
Fix issue 13208: document response body access exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wbamberg committed Jul 3, 2024
1 parent b03b097 commit fdf83db
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
8 changes: 8 additions & 0 deletions files/en-us/web/api/response/arraybuffer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions files/en-us/web/api/response/blob/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions files/en-us/web/api/response/bytes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
8 changes: 8 additions & 0 deletions files/en-us/web/api/response/formdata/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions files/en-us/web/api/response/json/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)),
Expand Down
5 changes: 5 additions & 0 deletions files/en-us/web/api/response/text/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down

0 comments on commit fdf83db

Please sign in to comment.