Class: Adcloud::ResponseErrorHandler

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/adcloud/response_error_handler.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/adcloud/response_error_handler.rb', line 7

def call(env)
  @app.call(env).on_complete do
    response = env[:response]
    # Todo comment in when ready
    # raise AdcloudUnknownAPIError::InvalidApiResponse unless response.body.has_key?("_meta")
    if response.success?
      response.body
    else
      Adcloud.logger.debug { response.inspect }
      ExceptionRaiser.new(response)
    end
  end
end