-
Notifications
You must be signed in to change notification settings - Fork 32
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 in full cause to thrown errors #94
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,18 +123,38 @@ export default function useButter(type, butterConfig) { | |
detail: errorDetail | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some cases error detail might be not in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for this @marcinpece-apptension, I've updated the code to handle a more general set of error keys/values. Please give this all another check. |
||
} = await errorPayload.response.json(); | ||
|
||
const mappedParams = Object.fromEntries( | ||
Object.entries(errorPayload.params) | ||
.filter(([key]) => key !== 'auth_token') | ||
); | ||
|
||
const url = new URL(errorPayload.response.url); | ||
|
||
// Remove auth_token from URL search params | ||
url.searchParams.delete('auth_token'); | ||
|
||
const cause = { | ||
data: errorDetail, | ||
headers: errorPayload.response.headers, | ||
status: errorPayload.response.status, | ||
statusText: errorPayload.response.statusText, | ||
config: errorPayload.config, | ||
params: mappedParams, | ||
type, | ||
url | ||
}; | ||
|
||
useOnError( | ||
errorDetail, | ||
{ | ||
config: errorPayload.config, | ||
params: errorPayload.params, | ||
type | ||
} | ||
cause | ||
); | ||
|
||
return Promise.reject( | ||
new Error( | ||
errorDetail | ||
`${ errorDetail } (${ errorPayload.response.status })`, | ||
{ | ||
cause | ||
} | ||
) | ||
); | ||
} else { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 have one error while running tests https://share.zight.com/L1uEo6mm