7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/qbo_api/raise_http_exception.rb', line 7
def call(env)
@app.call(env).on_complete do |response|
case response.status
when 200
when 400
raise QboApi::BadRequest.new(error_message(response))
when 401
raise QboApi::Unauthorized.new(error_message(response))
when 403
raise QboApi::Forbidden.new(error_message(response))
when 404
raise QboApi::NotFound.new(error_message(response))
when 429
raise QboApi::TooManyRequests.new(error_message(response))
when 500
raise QboApi::InternalServerError.new(error_message(response))
when 502
raise QboApi::BadGateway.new({ error_body: response.reason_phrase })
when 503
raise QboApi::ServiceUnavailable.new(error_message(response))
when 504
raise QboApi::GatewayTimeout.new(error_message(response))
end
end
end
|