Class: FaradayMiddleware::RockRMSErrorHandler

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/rock_rms/error.rb

Constant Summary collapse

ERROR_STATUSES =
400..600

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rock_rms/error.rb', line 19

def on_complete(env)
  case env[:status]
  when 400
    raise RockRMS::BadRequest, error_message(env)
  when 401
    raise RockRMS::Unauthorized, error_message(env)
  when 403
    raise RockRMS::Forbidden, error_message(env)
  when 404
    raise RockRMS::NotFound, error_message(env)
  when 500
    raise RockRMS::InternalServerError, error_message(env)
  when 502
    raise RockRMS::BadGateway, error_message(env)
  when 503
    raise RockRMS::ServiceUnavailable, error_message(env)
  when 504
    raise RockRMS::GatewayTimeout, error_message(env)
  when 520, 521, 522, 526
    raise RockRMS::CloudflareError, error_message(env)
  when ERROR_STATUSES
    raise RockRMS::Error, error_message(env)
  end

  check_html_error(env)
end