Module: PublishingPlatformApi::ExceptionHandling
- Included in:
- JsonClient
- Defined in:
- lib/publishing_platform_api/exceptions.rb
Instance Method Summary collapse
Instance Method Details
#build_specific_http_error(error, url, details = nil) ⇒ Object
73 74 75 76 77 |
# File 'lib/publishing_platform_api/exceptions.rb', line 73 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
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 106 107 108 109 110 111 112 113 114 |
# File 'lib/publishing_platform_api/exceptions.rb', line 79 def error_class_for_code(code) case code when 400 PublishingPlatformApi::HTTPBadRequest when 401 PublishingPlatformApi:: when 403 PublishingPlatformApi::HTTPForbidden when 404 PublishingPlatformApi::HTTPNotFound when 409 PublishingPlatformApi::HTTPConflict when 410 PublishingPlatformApi::HTTPGone when 413 PublishingPlatformApi::HTTPPayloadTooLarge when 422 PublishingPlatformApi::HTTPUnprocessableEntity when 429 PublishingPlatformApi::HTTPTooManyRequests when (400..499) PublishingPlatformApi::HTTPClientError when 500 PublishingPlatformApi::HTTPInternalServerError when 502 PublishingPlatformApi::HTTPBadGateway when 503 PublishingPlatformApi::HTTPUnavailable when 504 PublishingPlatformApi::HTTPGatewayTimeout when (500..599) PublishingPlatformApi::HTTPServerError else PublishingPlatformApi::HTTPErrorResponse end end |