Exception: X::TokenReportFailed
- Defined in:
- x-core/lib/x/core/errors/token_report_failed.rb
Overview
Error raised when save_tokens raised for the tokens of an exchange of a code or of a refresh
An authorization code works once, and so does a refresh token, so the tokens X issues for either are held in memory alone until save_tokens stores them: the first refresh token of X::OAuth2Authorization#client by the client it builds, and the one a refresh issued by the authenticator that refreshed, since the one it replaced is spent. They are not lost to a failure to store them, such as a database that is briefly down: the error holds them, so they can be stored again, and the client, which the exchange builds, or whose request refreshed. The error save_tokens raised is the cause, whose message the message ends with.
Instance Attribute Summary collapse
-
#client ⇒ Client?
readonly
The client the authorization built, or whose request refreshed the tokens.
-
#tokens ⇒ OAuth2Tokens?
readonly
The tokens of the exchange or the refresh, which save_tokens raised for.
Instance Method Summary collapse
-
#initialize(message = nil, client: nil, tokens: nil) ⇒ TokenReportFailed
constructor
Initialize the error with the client and the tokens it failed to report.
-
#to_s ⇒ String
The message, ending with why save_tokens raised.
Constructor Details
#initialize(message = nil, client: nil, tokens: nil) ⇒ TokenReportFailed
Initialize the error with the client and the tokens it failed to report
43 44 45 46 47 |
# File 'x-core/lib/x/core/errors/token_report_failed.rb', line 43 def initialize( = nil, client: nil, tokens: nil) @client = client @tokens = tokens super( || "The code was exchanged for tokens, but save_tokens raised for them") end |
Instance Attribute Details
#client ⇒ Client? (readonly)
The client the authorization built, or whose request refreshed the tokens
24 25 26 |
# File 'x-core/lib/x/core/errors/token_report_failed.rb', line 24 def client @client end |
#tokens ⇒ OAuth2Tokens? (readonly)
The tokens of the exchange or the refresh, which save_tokens raised for
32 33 34 |
# File 'x-core/lib/x/core/errors/token_report_failed.rb', line 32 def tokens @tokens end |
Instance Method Details
#to_s ⇒ String
The message, ending with why save_tokens raised
It ends with the message of the error save_tokens raised, which is the cause, if there is one.
57 |
# File 'x-core/lib/x/core/errors/token_report_failed.rb', line 57 def to_s = [super, cause&.].compact.join(": ") |