Module: ApiAdaptor::ExceptionHandling
- Included in:
- JsonClient
- Defined in:
- lib/api_adaptor/exceptions.rb
Instance Method Summary collapse
Instance Method Details
#build_specific_http_error(error, url, details = nil) ⇒ Object
64 65 66 67 68 |
# File 'lib/api_adaptor/exceptions.rb', line 64 def build_specific_http_error(error, url, details = nil) = "URL: #{url}\nResponse body:\n#{error.http_body}" code = error.http_code error_class_for_code(code).new(code, , details, error.http_body) end |
#error_class_for_code(code) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/api_adaptor/exceptions.rb', line 70 def error_class_for_code(code) case code when 400 ApiAdaptor::HTTPBadRequest when 401 ApiAdaptor::HTTPUnauthorized when 403 ApiAdaptor::HTTPForbidden when 404 ApiAdaptor::HTTPNotFound when 409 ApiAdaptor::HTTPConflict when 410 ApiAdaptor::HTTPGone when 413 ApiAdaptor::HTTPPayloadTooLarge when 422 ApiAdaptor::HTTPUnprocessableEntity when 429 ApiAdaptor::HTTPTooManyRequests when (400..499) ApiAdaptor::HTTPClientError when 500 ApiAdaptor::HTTPInternalServerError when 502 ApiAdaptor::HTTPBadGateway when 503 ApiAdaptor::HTTPUnavailable when 504 ApiAdaptor::HTTPGatewayTimeout when (500..599) ApiAdaptor::HTTPServerError else ApiAdaptor::HTTPErrorResponse end end |