Conversation
401, 413, 422, 429, and 529 had classes. 400, 403, 404, and every other 5xx arrived as a bare ApiError, so telling a malformed request from a revoked key from a wrong base URL from an outage meant reading #status and writing the branch yourself -- in a rescue, where a case on an integer is the worst place for it. Add BadRequest, PermissionDenied, NotFound, and ServerError, named after the classes the official Typesafe SDKs raise, so code written against those reads the same here. Overloaded becomes a ServerError: `rescue ServerError` now covers every 5xx including 529, and `rescue Overloaded` still picks out the one the API documents by name. The status-to-class mapping is a table rather than a case, and an undocumented status still lands on ApiError. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
401, 413, 422, 429 and 529 had classes. 400, 403, 404 and every other 5xx arrived as a bare
ApiError, so telling a malformed request from a revoked key from a wrong base URL from an outage meant reading#statusand writing the branch yourself — in arescue, where acaseon an integer is the worst place for it.Adds
BadRequest(400),PermissionDenied(403),NotFound(404) andServerError(any 5xx), named after the classes the official Typesafe SDKs raise, so code written against those reads the same here.Overloadedbecomes aServerError:rescue ServerErrornow covers every 5xx including 529, andrescue Overloadedstill picks out the one the API documents by name. The status-to-class mapping is a table rather than a case, and an undocumented status still lands onApiError.Tests
test/error_classes_test.rb, 8 cases covering every mapped status plus the fallbacks.Draft: part of a security and API-coverage audit, opened for reference rather than as a request for immediate review. Independent of the other branches, each off
main. Suite green on Ruby 3.2.11, 3.3.8 and 3.4.8.🤖 Generated with Claude Code