Exception: XxxRename::SiteClients::Errors::APIError
- Inherits:
-
StandardError
- Object
- StandardError
- XxxRename::SiteClients::Errors::APIError
- Defined in:
- lib/xxx_rename/site_clients/errors.rb
Direct Known Subclasses
BadGatewayError, BadRequestError, ForbiddenError, InternalServerError, NotFoundError, RedirectedError, TooManyRequestsError, UnauthorizedError, UnhandledError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #fetch_error_message ⇒ Object
-
#initialize(endpoint:, code:, body:, headers:) ⇒ APIError
constructor
A new instance of APIError.
- #message ⇒ Object
Constructor Details
#initialize(endpoint:, code:, body:, headers:) ⇒ APIError
Returns a new instance of APIError.
69 70 71 72 73 74 75 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 69 def initialize(endpoint:, code:, body:, headers:) @endpoint = endpoint @code = code @body = body @headers = headers super() end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
67 68 69 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 67 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
67 68 69 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 67 def code @code end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
67 68 69 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 67 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
67 68 69 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 67 def headers @headers end |
Instance Method Details
#fetch_error_message ⇒ Object
77 78 79 80 81 82 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 77 def case code when 302 then "unexpected redirection to #{headers["location"]}" else (body&.[]("error") || body&.[]("message") || body).to_s[0..150] end end |
#message ⇒ Object
84 85 86 87 88 89 |
# File 'lib/xxx_rename/site_clients/errors.rb', line 84 def "API Failure:\n" \ "\tURL: #{endpoint}\n" \ "\tRESPONSE CODE: #{code}\n" \ "\tERROR MESSAGE: #{}" end |