Exception: Ponto::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/ponto/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ Error

Returns a new instance of Error.



5
6
7
# File 'lib/ponto/error.rb', line 5

def initialize(errors)
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/ponto/error.rb', line 3

def errors
  @errors
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ponto/error.rb', line 9

def to_s
  if @errors && @errors.size > 0
    @errors.map do |error|
      p error
      if error["meta"] && error["meta"]["attribute"]
        "* #{error["code"]}: '#{error["meta"]["attribute"]}' #{error["detail"]}"
      elsif error["meta"] && error["meta"]["resource"]
        "* #{error["code"]}: '#{error["meta"]["resource"]}' #{error["detail"]}"
      else
        "* #{error["code"]}: #{error["detail"]}"
      end
    end.join("\n")
  else
    super
  end
end