Exception: Conekta::Error
- Inherits:
-
Exception
- Object
- Exception
- Conekta::Error
- Defined in:
- lib/conekta/error.rb
Direct Known Subclasses
ApiError, AuthenticationError, MalformedRequestError, NoConnectionError, ParameterValidationError, ProcessingError, ResourceNotFoundError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#custom_message ⇒ Object
readonly
NEW FIELDS.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#message_to_purchaser ⇒ Object
readonly
Returns the value of attribute message_to_purchaser.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#type ⇒ Object
readonly
DEPRECATED.
-
#validation_error ⇒ Object
readonly
NEW FIELDS.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
-
#initialize(options = {}) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(options = {}) ⇒ Error
Returns a new instance of Error.
10 11 12 13 14 15 16 17 18 |
# File 'lib/conekta/error.rb', line 10 def initialize(={}) @message = ["message"] @message_to_purchaser = ["message_to_purchaser"] @param = ["param"] @code = ["code"] @validation_error = ["validation_error"] @validation_error = ["custom_message"] @type = ["type"] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def code @code end |
#custom_message ⇒ Object (readonly)
NEW FIELDS
5 6 7 |
# File 'lib/conekta/error.rb', line 5 def @custom_message end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def @message end |
#message_to_purchaser ⇒ Object (readonly)
Returns the value of attribute message_to_purchaser.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def @message_to_purchaser end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def param @param end |
#type ⇒ Object (readonly)
DEPRECATED.
7 8 9 |
# File 'lib/conekta/error.rb', line 7 def type @type end |
#validation_error ⇒ Object (readonly)
NEW FIELDS
5 6 7 |
# File 'lib/conekta/error.rb', line 5 def validation_error @validation_error end |
Class Method Details
.error_handler(response, http_status) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/conekta/error.rb', line 22 def self.error_handler(response, http_status) if http_status.to_s.empty? || http_status == 0 NoConnectionError.new({ "message" => I18n.t('error.requestor.connection', { base: Conekta.api_base, locale: :en }), "message_to_purchaser" => I18n.t('error.requestor.connection_purchaser', { locale: Conekta.locale.to_sym }) }) else case http_status when 400 MalformedRequestError.new(response) when 401 AuthenticationError.new(response) when 402 ProcessingError.new(response) when 404 ResourceNotFoundError.new(response) when 422 ParameterValidationError.new(response) when 500 ApiError.new(response) else Error.new(response) end end end |
Instance Method Details
#class_name ⇒ Object
19 20 21 |
# File 'lib/conekta/error.rb', line 19 def class_name self.class.name.split('::')[-1] end |