-
Notifications
You must be signed in to change notification settings - Fork 373
Revamp error hierarchy #722
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
Open
anakinj
wants to merge
6
commits into
jwt:main
Choose a base branch
from
anakinj:error-hierarchy-revamp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eca0900
Revamp error hierarchy
anakinj 7691417
More specific exception assertions and specific error types
anakinj cb3c24d
Deprecation comment
anakinj 88d7d7e
Changelog entry
anakinj c16d7d4
React on copilot comments
anakinj 2f4926c
Make specs test what they claim they are testing
anakinj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,69 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module JWT | ||
| # The base error class for all JWT errors. | ||
| class Error < StandardError; end | ||
|
|
||
| # The EncodeError class is raised when there is an error encoding a JWT. | ||
| class EncodeError < StandardError; end | ||
| class EncodeError < Error; end | ||
|
|
||
| # The DecodeError class is raised when there is an error decoding a JWT. | ||
| class DecodeError < StandardError; end | ||
| # The TokenError class is the base class for all errors related to token processing. | ||
| class TokenError < Error; end | ||
|
|
||
| # The VerificationError class is raised when there is an error verifying a JWT. | ||
| class VerificationError < DecodeError; end | ||
| # The MalformedTokenError class is raised when the token is structurally invalid. | ||
| class MalformedTokenError < TokenError; end | ||
|
|
||
| # The ExpiredSignature class is raised when the JWT signature has expired. | ||
| class ExpiredSignature < DecodeError; end | ||
| # The Base64DecodeError class is raised when there is an error decoding a Base64-encoded string. | ||
| class Base64DecodeError < MalformedTokenError; end | ||
|
|
||
| # The IncorrectAlgorithm class is raised when the JWT algorithm is incorrect. | ||
| class IncorrectAlgorithm < DecodeError; end | ||
| # The SignatureError class is the base class for signature and algorithm related errors. | ||
| class SignatureError < TokenError; end | ||
|
|
||
| # The ImmatureSignature class is raised when the JWT signature is immature. | ||
| class ImmatureSignature < DecodeError; end | ||
| # The VerificationError class is raised when there is an error verifying a JWT signature. | ||
| class VerificationError < SignatureError; end | ||
|
|
||
| # The InvalidIssuerError class is raised when the JWT issuer is invalid. | ||
| class InvalidIssuerError < DecodeError; end | ||
| # The IncorrectAlgorithm class is raised when the JWT algorithm is incorrect. | ||
| class IncorrectAlgorithm < SignatureError; end | ||
|
|
||
| # The UnsupportedEcdsaCurve class is raised when the ECDSA curve is unsupported. | ||
| class UnsupportedEcdsaCurve < IncorrectAlgorithm; end | ||
|
|
||
| # The ClaimValidationError class is the base class for all claim validation errors. | ||
| class ClaimValidationError < TokenError; end | ||
|
|
||
| # The ExpiredSignature class is raised when the JWT token has expired. | ||
| class ExpiredSignature < ClaimValidationError; end | ||
|
|
||
| # The ImmatureSignature class is raised when the JWT token is not yet valid (nbf). | ||
| class ImmatureSignature < ClaimValidationError; end | ||
|
|
||
| # The InvalidIssuerError class is raised when the JWT issuer is invalid. | ||
| class InvalidIssuerError < ClaimValidationError; end | ||
|
|
||
| # The InvalidIatError class is raised when the JWT issued at (iat) claim is invalid. | ||
| class InvalidIatError < DecodeError; end | ||
| class InvalidIatError < ClaimValidationError; end | ||
|
|
||
| # The InvalidAudError class is raised when the JWT audience (aud) claim is invalid. | ||
| class InvalidAudError < DecodeError; end | ||
| class InvalidAudError < ClaimValidationError; end | ||
|
|
||
| # The InvalidSubError class is raised when the JWT subject (sub) claim is invalid. | ||
| class InvalidSubError < DecodeError; end | ||
| class InvalidSubError < ClaimValidationError; end | ||
|
|
||
| # The InvalidCritError class is raised when the JWT crit header is invalid. | ||
| class InvalidCritError < DecodeError; end | ||
| class InvalidCritError < ClaimValidationError; end | ||
|
|
||
| # The InvalidJtiError class is raised when the JWT ID (jti) claim is invalid. | ||
| class InvalidJtiError < DecodeError; end | ||
| class InvalidJtiError < ClaimValidationError; end | ||
|
|
||
| # The InvalidPayload class is raised when the JWT payload is invalid. | ||
| class InvalidPayload < DecodeError; end | ||
| class InvalidPayload < ClaimValidationError; end | ||
|
|
||
| # The MissingRequiredClaim class is raised when a required claim is missing from the JWT. | ||
| class MissingRequiredClaim < DecodeError; end | ||
|
|
||
| # The Base64DecodeError class is raised when there is an error decoding a Base64-encoded string. | ||
| class Base64DecodeError < DecodeError; end | ||
| class MissingRequiredClaim < ClaimValidationError; end | ||
|
|
||
| # The JWKError class is raised when there is an error with the JSON Web Key (JWK). | ||
| class JWKError < DecodeError; end | ||
| class JWKError < Error; end | ||
|
|
||
| # @deprecated Use {JWT::Error}, {JWT::TokenError}, or a more specific error class instead. | ||
| DecodeError = Error | ||
| end |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.