Exception: FinchAPI::Errors::APIStatusError
- Defined in:
- lib/finch_api/errors.rb
Direct Known Subclasses
AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError
Instance Attribute Summary collapse
Attributes inherited from APIError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url:, status:, body:, request:, response:, message: nil) ⇒ APIStatusError
constructor
private
A new instance of APIStatusError.
Constructor Details
#initialize(url:, status:, body:, request:, response:, message: nil) ⇒ APIStatusError
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of APIStatusError.
147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/finch_api/errors.rb', line 147 def initialize(url:, status:, body:, request:, response:, message: nil) ||= {url: url.to_s, status: status, body: body} super( url: url, status: status, body: body, request: request, response: response, message: &.to_s ) end |
Instance Attribute Details
#status ⇒ Integer
2 3 4 |
# File 'lib/finch_api/errors.rb', line 2 def status @status end |
Class Method Details
.for(url:, status:, body:, request:, response:, message: nil) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/finch_api/errors.rb', line 103 def self.for(url:, status:, body:, request:, response:, message: nil) kwargs = { url: url, status: status, body: body, request: request, response: response, message: } case status in 400 FinchAPI::Errors::BadRequestError.new(**kwargs) in 401 FinchAPI::Errors::AuthenticationError.new(**kwargs) in 403 FinchAPI::Errors::PermissionDeniedError.new(**kwargs) in 404 FinchAPI::Errors::NotFoundError.new(**kwargs) in 409 FinchAPI::Errors::ConflictError.new(**kwargs) in 422 FinchAPI::Errors::UnprocessableEntityError.new(**kwargs) in 429 FinchAPI::Errors::RateLimitError.new(**kwargs) in (500..) FinchAPI::Errors::InternalServerError.new(**kwargs) else FinchAPI::Errors::APIStatusError.new(**kwargs) end end |