Exception: Conekta::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Conekta::Error
- Defined in:
- lib/conekta/error.rb
Direct Known Subclasses
ApiError, AuthenticationError, MalformedRequestError, NoConnectionError, ParameterValidationError, PreconditionRequiredError, ProcessingError, ResourceNotFoundError, VersionConflictError
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#log_id ⇒ Object
readonly
Returns the value of attribute log_id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
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.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/conekta/error.rb', line 5 def initialize(={}) @type = ["type"] @log_id = ["log_id"] if ["details"] @details = ["details"].collect{|details| Conekta::ErrorDetails.new(details) } else temp_details = Conekta::ErrorDetails.new({ "message" => ["message_to_purchaser"], "debug_message" => ["message"], "param" => ["param"] }) @details = [temp_details] end @message = @details.first. @data = ["data"] super end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def data @data end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def details @details end |
#log_id ⇒ Object (readonly)
Returns the value of attribute log_id.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def log_id @log_id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/conekta/error.rb', line 3 def type @type end |
Class Method Details
.error_handler(response, http_status) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/conekta/error.rb', line 30 def self.error_handler(response, http_status) if http_status.to_s.empty? || http_status == 0 NoConnectionError.new({ "details" => [ { "debug_message" => I18n.translate( 'error.requestor.connection', locale: :en, base: Conekta.api_base ), "message" => I18n.translate( 'error.requestor.connection_purchaser', locale: Conekta.locale.to_sym ), "code" => "error.requestor.connection" } ] }) else case http_status when -1, 0 NoConnectionError.new(response) when 400 MalformedRequestError.new(response) when 401 AuthenticationError.new(response) when 402 ProcessingError.new(response) when 404 ResourceNotFoundError.new(response) when 409 VersionConflictError.new(response) when 422 ParameterValidationError.new(response) when 428 PreconditionRequiredError.new(response) when 500 ApiError.new(response) else Error.new(response) end end end |
Instance Method Details
#class_name ⇒ Object
26 27 28 |
# File 'lib/conekta/error.rb', line 26 def class_name self.class.name.split('::')[-1] end |