Skip to content
Myr

Fix incorrect documentation and add example (#462)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Mikael Finstad · committed by GitHub · parent 430486b · Browse files · 2 files+14 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−2 removed

  • other:+14 added−2 removed

2 files+14 added−2 removed

modified:source/types/hooks.ts+1 added-1 removed
modified:readme.md+13 added-1 removed
273 unmodified lines
274 error => {275 const {response} = error;276 if (response && response.body) {277 error.name = 'GitHubError';278 error.message = `${response.body.message} (${response.statusCode})`;278 error.message = `${response.body.message} (${response.status})`;279 }280281 return error;282 }
207 unmodified lines
490### HTTPError491492Exposed for `instanceof` checks. The error has a `response` property with the [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response), `request` property with the [`Request` object](https://developer.mozilla.org/en-US/docs/Web/API/Request), and `options` property with normalized options (either passed to `ky` when creating an instance with `ky.create()` or directly when performing the request).493494If you need to read the actual response when an `HTTPError` has occurred, call the respective parser method on the response object. For example:495496```js497try {498 await ky('https://example.com').json();499} catch (error) {500 if (error.name === 'HTTPError') {501 const errorJson = await error.response.json();502 }503}504```505506### TimeoutError507508The error thrown when the request times out. It has a `request` property with the [`Request` object](https://developer.mozilla.org/en-US/docs/Web/API/Request).509
143 unmodified lines