Class: Faraday::TwOntologyErrors::Middleware

Inherits:
Middleware
  • Object
show all
Defined in:
lib/hookkaido/faraday.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  @app.call(env).on_complete do |response|
    case response[:status].to_i
    when 400 then raise Hookkaido::BadRequest,  compose(response)
    when 404 then raise Hookkaido::NotFound,    compose(response)
    when 500 then raise Hookkaido::InternalServerError, compose(response)
    when 502 then raise Hookkaido::BadGateway,  compose(response)
    when 503 then raise Hookkaido::ServiceUnavailable,  compose(response)
    when 504 then raise Hookkaido::GatewayTimeout,      compose(response)
    end
  end
end