Add error handler for RateLimit error#128
Merged
drish merged 3 commits intoresend:mainfrom Oct 1, 2025
Merged
Conversation
…rror handling in `handle_error!`.
Contributor
Author
|
@drish |
Contributor
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="lib/resend/errors.rb">
<violation number="1" location="lib/resend/errors.rb:24">
RateLimitExceededError needs to pass the headers up to Error#initialize so error.headers exposes the actual response headers.</violation>
</file>
<file name="lib/resend/request.rb">
<violation number="1" location="lib/resend/request.rb:50">
`resp[:headers]` reads the parsed JSON body, not the HTTP headers exposed by HTTParty, so the rate limit metadata will always be empty. Please pull the headers from `resp.headers` instead so RateLimitExceededError receives the real values.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
drish
approved these changes
Oct 1, 2025
Member
|
this is great @NerdyBoyCool , thank you for your contribution ! |
Contributor
Author
|
@drish I'll leave the timing of releases and merges to the repository owner! |
Member
ill merge this and have a release going soon |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref: #31
ref: https://resend.com/docs/api-reference/rate-limit
Thank you for developing Ruby SDK.
Summary
When calling the Resend API from Ruby/Rails applications, we need to properly handle rate limit errors. Currently,
RateLimitExceededErrordoesn't provide information.This PR enhances rate limit error handling by adding detailed rate limit information to
RateLimitExceededError.Changes
enabling errors to access rate limit information from API responses
instantiation with headers
rate limit headers
Summary by cubic
Add detailed rate limit data to RateLimitExceededError and propagate response headers when raising errors. Apps can now read limit, remaining, reset, and retry-after to implement proper backoff.