Skip to content

Commit

Permalink
Better exception hadling, version 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmendes committed Dec 18, 2015
1 parent 6b753d5 commit bbb454c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
This file is a manually maintained list of changes for each release. Feel free to add your
changes here when sending pull requests. Also send corrections if you spot any mistakes.

## v2.0.4 (2015-12-18)
* Better exception and error handling

## v2.0.3 (2015-12-09)
* Added campaign resource's merge call, for propagating campaign pass data changes
to all of it's passes.
Expand Down
6 changes: 3 additions & 3 deletions lib/passworks/faraday/http_exception_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(app)

private
def error_400(response)
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]} - #{error_body(response)}"
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}\n#{error_body(response)}"
end

def error_500(response, short_description, long_description)
Expand All @@ -63,8 +63,8 @@ def error_body(response)

if body.nil?
nil
elsif body['message']
"(#{body['error_code']}) #{body['message']}"
elsif body['errors']
body['errors'].collect{ |k,v| "#{k}: #{v.join(',')}" }.join("\n")
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/passworks/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def agent
connection.use Passworks::Faraday::HttpExceptionMiddleware
connection.adapter ::Faraday.default_adapter
end
@agent.headers[:user_agent] = @user_agent
# always return the {@agent}
@agent.headers[:user_agent] = @user_agent
@agent.headers['Content-Type'] = 'application/json'
@agent
end

Expand Down
2 changes: 1 addition & 1 deletion lib/passworks/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Passworks
VERSION = "2.0.3"
VERSION = "2.0.4"
end

0 comments on commit bbb454c

Please sign in to comment.