Exception: PaypalClient::Errors::Error
- Inherits:
-
StandardError
- Object
- StandardError
- PaypalClient::Errors::Error
- Defined in:
- lib/paypal_client/errors.rb
Direct Known Subclasses
AuthenticationFailure, InternalServerError, InvalidRequest, MediaTypeNotAcceptable, MethodNotSupported, NotAuthorized, RateLimitReached, ResourceNotFound, ServiceUnavailable, UnprocessableEntity, UnsupportedMediaType
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
- #inspect ⇒ Object
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/paypal_client/errors.rb', line 11 def initialize(response) @status_code = response.status @body = response.body if @body.class == Hash @error = @body[:name] if @body.key?(:name) = @body[:message] if @body.key?(:message) else @error = response.reason_phrase if @error.nil? end super(@error) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/paypal_client/errors.rb', line 7 def body @body end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/paypal_client/errors.rb', line 8 def error @error end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
9 10 11 |
# File 'lib/paypal_client/errors.rb', line 9 def end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/paypal_client/errors.rb', line 6 def status_code @status_code end |
Instance Method Details
#inspect ⇒ Object
24 25 26 27 28 29 |
# File 'lib/paypal_client/errors.rb', line 24 def inspect extra = '' extra << " status_code: #{status_code.inspect}" unless status_code.nil? extra << " body: #{body.inspect}" unless body.nil? "#<#{self.class.name}: #{message}#{extra}>" end |