Class: UspsApi::OauthStandardErrorResponseException
- Inherits:
-
APIException
- Object
- CoreLibrary::ApiException
- APIException
- UspsApi::OauthStandardErrorResponseException
- Defined in:
- lib/usps_api/exceptions/oauth_standard_error_response_exception.rb
Overview
The authorization server responds with an HTTP 400 (Bad Request) status code (unless specified otherwise) and includes the following parameters with the response.
Instance Attribute Summary collapse
-
#error ⇒ Error8
See [The OAuth 2.0 Authorization Framework, Section 5.2](datatracker.ietf.org/doc/html/rfc6749#section-5.2), for information about the specific error codes.
-
#error_description ⇒ String
A human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.
-
#error_uri ⇒ String
A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
Instance Method Summary collapse
-
#initialize(reason, response) ⇒ OauthStandardErrorResponseException
constructor
The constructor.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, response) ⇒ OauthStandardErrorResponseException
The constructor.
34 35 36 37 38 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 34 def initialize(reason, response) super(reason, response) hash = APIHelper.json_deserialize(@response.raw_body) unbox(hash) end |
Instance Attribute Details
#error ⇒ Error8
See [The OAuth 2.0 Authorization Framework, Section 5.2](datatracker.ietf.org/doc/html/rfc6749#section-5.2), for information about the specific error codes.
18 19 20 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 18 def error @error end |
#error_description ⇒ String
A human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.
23 24 25 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 23 def error_description @error_description end |
#error_uri ⇒ String
A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
29 30 31 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 29 def error_uri @error_uri end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
60 61 62 63 64 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 60 def inspect class_name = self.class.name.split('::').last "<#{class_name} error: #{@error.inspect}, error_description: #{@error_description.inspect},"\ " error_uri: #{@error_uri.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
53 54 55 56 57 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 53 def to_s class_name = self.class.name.split('::').last "<#{class_name} error: #{@error}, error_description: #{@error_description}, error_uri:"\ " #{@error_uri}>" end |
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
43 44 45 46 47 48 49 50 |
# File 'lib/usps_api/exceptions/oauth_standard_error_response_exception.rb', line 43 def unbox(hash) return nil unless hash @error = hash.key?('error') ? hash['error'] : SKIP @error_description = hash.key?('error_description') ? hash['error_description'] : SKIP @error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP end |