class PDC::JsonError

Public Instance Methods

message() click to toggle source
# File lib/pdc/http/errors.rb, line 19
def message
  summary = detail || response.body
  "Error: #{status} - #{summary}"
end

Private Instance Methods

detail() click to toggle source

returns details in json response if any, else nil

# File lib/pdc/http/errors.rb, line 27
def detail
  @detail ||= json[:detail]
end
json() click to toggle source

tries to parse response body as a json

# File lib/pdc/http/errors.rb, line 32
def json
  @json ||= begin
              MultiJson.load(response.body, symbolize_keys: true)
            rescue MultiJson::ParseError
              {}
            end
end