FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Injects rate_limit_details on RateLimitExceeded exception by diaclavijo · Pull Request #624 · intercom/intercom-ruby · GitHub

Injects rate_limit_details on RateLimitExceeded exception - #624

Open
diaclavijo wants to merge 1 commit into
intercom:masterfrom
diaclavijo:inject-rate-limit-details-on-exception-attrs
Open

Injects rate_limit_details on RateLimitExceeded exception#624
diaclavijo wants to merge 1 commit into
intercom:masterfrom
diaclavijo:inject-rate-limit-details-on-exception-attrs

Conversation

Copy link
Copy Markdown

Why?

This would allow a user of the API to rescue for example in an ApplicationJob and retry when the time has passed, rather than sleeping.

def perform
  req.execute(uri, token: 'test-token')
rescue Intercom::RateLimitExceeded => e
  self.class.perform_at(e.rate_limit_details[:reset_at])
end

How?

  • Adds attr_accessor to RateLimitExceeded on errors.rb
  • Intercom::Request#execute rescue block injects the @rate_limit_details before raising the exception

- Why?
This would allow a user of the API to rescue for example in an ApplicationJob and retry when the time has passed, rather than sleeping.

```
def perform
  req.execute(uri, token: 'test-token')
rescue Intercom::RateLimitExceeded => e
  self.class.perform_at(e.rate_limit_details[:reset_at])
end
```

- How?

* Adds attr_accessor to RateLimitExceeded on errors.rb
* Intercom::Request#execute rescue block injects the  @rate_limit_details before raising the exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL