Exception: Safire::Errors::TokenError
- Defined in:
- lib/safire/errors.rb
Overview
Raised for token exchange or refresh failures.
Two usage paths: - HTTP failure: provide status, error_code, and/or error_description - Structural failure (missing access_token): provide received_fields
Instance Attribute Summary collapse
-
#error_code ⇒ String?
readonly
OAuth2
errorfield (e.g. +“invalid_grant”+). -
#error_description ⇒ String?
readonly
OAuth2
error_descriptionfield. -
#received_fields ⇒ Array<String>?
readonly
Field names present in an invalid token response (no values).
-
#status ⇒ Integer?
readonly
HTTP status code.
Instance Method Summary collapse
-
#initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) ⇒ TokenError
constructor
A new instance of TokenError.
Constructor Details
#initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) ⇒ TokenError
Returns a new instance of TokenError.
120 121 122 123 124 125 126 |
# File 'lib/safire/errors.rb', line 120 def initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) @status = status @error_code = error_code @error_description = error_description @received_fields = received_fields super() end |
Instance Attribute Details
#error_code ⇒ String? (readonly)
Returns OAuth2 error field (e.g. +“invalid_grant”+).
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/safire/errors.rb', line 117 class TokenError < Error attr_reader :status, :error_code, :error_description, :received_fields def initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) @status = status @error_code = error_code @error_description = error_description @received_fields = received_fields super() end private def if @received_fields "Missing access token in response; received fields: #{@received_fields.join(', ')}" else parts = ['Token request failed'] parts << "HTTP #{@status}" if @status parts << @error_code if @error_code parts << @error_description if @error_description parts.join(' — ') end end end |
#error_description ⇒ String? (readonly)
Returns OAuth2 error_description field.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/safire/errors.rb', line 117 class TokenError < Error attr_reader :status, :error_code, :error_description, :received_fields def initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) @status = status @error_code = error_code @error_description = error_description @received_fields = received_fields super() end private def if @received_fields "Missing access token in response; received fields: #{@received_fields.join(', ')}" else parts = ['Token request failed'] parts << "HTTP #{@status}" if @status parts << @error_code if @error_code parts << @error_description if @error_description parts.join(' — ') end end end |
#received_fields ⇒ Array<String>? (readonly)
Returns field names present in an invalid token response (no values).
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/safire/errors.rb', line 117 class TokenError < Error attr_reader :status, :error_code, :error_description, :received_fields def initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) @status = status @error_code = error_code @error_description = error_description @received_fields = received_fields super() end private def if @received_fields "Missing access token in response; received fields: #{@received_fields.join(', ')}" else parts = ['Token request failed'] parts << "HTTP #{@status}" if @status parts << @error_code if @error_code parts << @error_description if @error_description parts.join(' — ') end end end |
#status ⇒ Integer? (readonly)
Returns HTTP status code.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/safire/errors.rb', line 117 class TokenError < Error attr_reader :status, :error_code, :error_description, :received_fields def initialize(status: nil, error_code: nil, error_description: nil, received_fields: nil) @status = status @error_code = error_code @error_description = error_description @received_fields = received_fields super() end private def if @received_fields "Missing access token in response; received fields: #{@received_fields.join(', ')}" else parts = ['Token request failed'] parts << "HTTP #{@status}" if @status parts << @error_code if @error_code parts << @error_description if @error_description parts.join(' — ') end end end |