Skip to content

Commit

Permalink
Handle json parsing errors and fall back to inspect for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Apr 21, 2017
1 parent 762bb6b commit 60aa11a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/httparty
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ else
when :json
begin
require 'json'
puts JSON.pretty_generate(response)
puts JSON.pretty_generate(response.parsed_response)
rescue LoadError
puts YAML.dump(response)
rescue JSON::JSONError
puts response.inspect
end
when :xml
require 'rexml/document'
Expand Down

0 comments on commit 60aa11a

Please sign in to comment.