class ChimeraHttpClient::Deserializer

Public Class Methods

json_error() click to toggle source
# File lib/chimera_http_client/deserializer.rb, line 14
def json_error
  proc do |body|
    JSON.parse(body)
  rescue JSON::ParserError
    { "non_json_body" => body }
  end
end
json_response() click to toggle source
# File lib/chimera_http_client/deserializer.rb, line 22
def json_response
  proc do |body|
    JSON.parse(body)
  rescue JSON::ParserError => e
    raise ::ChimeraHttpClient::JsonParserError, "Could not parse body as JSON: #{body}, error: #{e.message}"
  end
end