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
Listen for errors globally #1846
Comments
Hello @davidbielik, thank you for the feature request. There is currently no good way to do this. You might be able to accomplish something close to what you need by providing a custom import Stripe from "stripe";
const myHttpClient = Stripe.createNodeHttpClient()
const makeRequest = myHttpClient.makeRequest.bind(myHttpClient)
myHttpClient.makeRequest =(...args) => {
return makeRequest(...args).then((res) => {
if (res.getStatusCode() >= 400) {
callYourCustomErrorHandlerHere(res)
}
return res
})
}}
const stripe = new Stripe("sk_test_xyz", { httpClient: myHttpClient }); This will let you register an error handler using the raw HTTP responses received by |
I'll leave this open as a feature request. I think a more thoughtfully-designed mechanism for "globally" extending the library / the ability to intercept/handle errors and successes at a higher level than raw http would be a good addition, but it's not something on the team's immediate roadmap. |
Is your feature request related to a problem? Please describe.
I would like to listen for errors in my Stripe calls so that I can log to my error tracking service.
I see there is
stripe.on("response", (response) => {})
but it doesn't have the same details as theStripeError
object.I also noticed while upgrading my package version that you provide nice details like
request_log_url
(https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#10140---2022-10-13).Is there a way to listen for all stripe response errors?
Describe the solution you'd like
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: