-
-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add beforeError
hook
#417
Add beforeError
hook
#417
Conversation
Linting is not passing. Make sure you always run |
It needs to be documented in the readme too. |
@sindresorhus I see this error which is not related to my changes: any idea what to be done about it? |
@sindresorhus Any update in this? |
source/types/hooks.ts
Outdated
|
||
/** | ||
Called with `HTTPError` instance. The error is passed to the hook right before it's thrown. | ||
This is especially useful when you want to have more detailed errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readme and TS docs should be in sync.
readme.md
Outdated
Type: `Function[]`\ | ||
Default: `[]` | ||
|
||
This hook enables you to modify the HTTPError right before it is thrown. The hook function receives `HTTPError` as argument and should return instance of HTTPError. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hook enables you to modify the HTTPError right before it is thrown. The hook function receives `HTTPError` as argument and should return instance of HTTPError. | |
This hook enables you to modify the `HTTPError` right before it is thrown. The hook function receives `HTTPError` as argument and should return instance of `HTTPError`. |
readme.md
Outdated
await ky('https://example.com', { | ||
hooks: { | ||
beforeError: [ | ||
(error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(error) => { | |
error => { |
Fixes #412