Exception: Epayco::Error

Inherits:
StandardError
  • Object
show all
Includes:
Enumerable
Defined in:
lib/epayco.rb

Overview

Set custom error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, lang) ⇒ Error

Get code, lang and show custom error



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/epayco.rb', line 18

def initialize code, lang
  file = open("https://multimedia.epayco.co/message-api/errors.json").read
  data_hash = JSON.parse(file)
  error = "Error"
  if(data_hash[code.to_s])
    error = [data_hash[code.to_s][lang]]
  else
    error = [code, lang]
  end
  super error
  @errors = error
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



15
16
17
# File 'lib/epayco.rb', line 15

def errors
  @errors
end

Instance Method Details

#eachObject



31
32
33
# File 'lib/epayco.rb', line 31

def each
  @errors.each { |e| yield *e }
end