#Matt11-ratelimite
1 messages · Page 1 of 1 (latest)
thank you!
another question
how can I listen for error 429?
I'm calling the Stripe::Subscription.update API but it returns the subscription or an error message
how can I listen for error 429?
What do you mean by "listen"? 429 means a rate limit error.
To handle rate limit errors, we recommend following this: https://stripe.com/docs/error-handling?#rate-limit-errors
here https://stripe.com/docs/rate-limits#handling-limiting-gracefully it says: "A basic technique for integrations to gracefully handle limiting is to watch for 429 status codes and build in a retry mechanism"
how can I watch for 429 status?
rescue Stripe::RateLimitError?
When you code calls the Stripe API, you check the response returned by Stripe. If it's a 429, then wait for some relay and retry your call.
I cannot access the response status directly
this is a response #<Stripe::InvalidRequestError: (Status 404) (Request req_31PEIRQUlc62xN) No such subscription: 'sub_1Kkr3OApMCw5clA3RucvxHLY'>
let's say res = Stripe::Subscription.update(stripe_subscription_id, { cancel_at_period_end: false }), I cannot call the res.status, res.status_code, etc
In general you should catch the errors Stripe return, this is explained on this page: https://stripe.com/docs/error-handling
Also the error you just shared is not about rate limits, since the code is 404 and not 429.
this is the only example I was able to reproduce
Note that the subscription sub_1Kkr3OApMCw5clA3RucvxHLY doesn't exist, so it's expected to return a 404.
I know
So can you clarify your question? What exactly are you trying to do? And have you followed this guide to handle errors? https://stripe.com/docs/error-handling
suppose I receive a 429 and I catch the Stripe::RateLimitError. How can I access the params given to the request?
Eg: res = Stripe::Subscription.update('abcdef', { cancel_at_period_end: false }) how can I access the 'abcdef' param?
What programming language are you using? Ruby?
Yes
I'm not very familiar with Ruby, but have you seen this code to catch exceptions in Ruby?
https://stripe.com/docs/error-handling?lang=ruby#catch-exceptions