Skip to content

Commit

Permalink
gather error causes from API response in 'errors' array
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Caramello committed Nov 13, 2015
1 parent ecccb1e commit a00c4af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/td/client/api.rb
Expand Up @@ -591,7 +591,13 @@ def parse_error_response(res)
if js.nil?
error['message'] = res.reason
else
error['message'] = js['message'] || js['error']
# js = {"errors"=>{"cron"=>["Invalid cron specification", "Another error"],"another_par"=>["Message for another parameter"]}} => "cron: Invalid cron specification, Another error. another_par: Message for another parameter"
# js = {"message"=>"This is an error message"} => "This is an error message"
# js = {"error"=>"This is an error message"} => "This is an error message"
error['message'] = \
js['message'] || \
js['error'] || \
js['errors'].map{|k,v| "#{k}: #{v.join(", ")}"}.join(". ")
error['stacktrace'] = js['stacktrace']
end
rescue JSON::ParserError
Expand Down

0 comments on commit a00c4af

Please sign in to comment.