Class: Easyship::Middleware::ErrorHandlerMiddleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/easyship/middleware/error_handler_middleware.rb

Overview

Response middleware that raises an error based on the response status code

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/easyship/middleware/error_handler_middleware.rb', line 9

def on_complete(env)
  status_code = env[:status].to_i
  body = response_body(env[:body])

  handle_status_code(status_code, body)
end