-
Notifications
You must be signed in to change notification settings - Fork 352
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
feat: Add error
event and improve error handling
#185
Conversation
error || new Error('[Polly] Request failed due to an unknown error.'); | ||
|
||
await pollyRequest._emit('error', error); | ||
await this.respondToRequest(pollyRequest, 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.
Call respondToRequest
with an error if the request failed so that the adapters can gracefully handle it.
@@ -13,10 +13,6 @@ export default class Logger { | |||
this.groupName = null; | |||
} | |||
|
|||
get enabled() { |
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.
Removing dead/unused code.
@@ -22,7 +22,7 @@ export default function request(url, obj = {}) { | |||
xhr.status === 204 && xhr.responseText === '' ? null : xhr.responseText; | |||
|
|||
return new Response(responseBody, { | |||
status: xhr.status, | |||
status: xhr.status || 500, |
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.
I realize this is just pertaining to a test util but can the fallback mask a future bug in our test suite?
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 will only happen when status is 0
which occurs when we do xhr.error()
. Do you have a better way around this? Response wont accept a status code of 0
|
||
// Remove all adapter & persister config options as they can cause a circular | ||
// structure to the final JSON | ||
['adapter', 'adapterOptions', 'persister', 'persisterOptions'].forEach( |
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.
Is this a fix for separate bug?
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 is a fix for a separate bug that I found when tackling this.
Resolves #181