Method: F00px::Error.parse_error

Defined in:
lib/f00px/error.rb

.parse_error(body) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/f00px/error.rb', line 16

def parse_error(body)
  return body if body.is_a? String
  if body.nil?
    ''
  elsif body[:error]
    body[:error]
  elsif body[:errors]
    first = Array(body[:errors]).first
    if first.is_a?(Hash)
      first[:message].chomp
    else
      first.chomp
    end
  end
end