Class: PagerDuty::Connection::RaiseApiErrorOnNon200
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- PagerDuty::Connection::RaiseApiErrorOnNon200
- Defined in:
- lib/pager_duty/connection.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pager_duty/connection.rb', line 30 def call(env) response = @app.call env unless [200, 201, 204].include?(response.status) url = response.env[:url].to_s = "Got HTTP #{response['status']} back for #{url}" if error = response.body['error'] # TODO May Need to check error.errors too += "\n#{error.to_hash}" end raise ApiError, else response end end |