Exception: Basecamp::ApiError
- Defined in:
- lib/basecamp/api_error.rb
Overview
Raised for generic API errors.
Class Method Summary collapse
-
.from_status(status, message = nil) ⇒ ApiError
Creates an ApiError from an HTTP status code.
Instance Method Summary collapse
-
#initialize(message, http_status: nil, hint: nil, retryable: false, cause: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(message, http_status: nil, hint: nil, retryable: false, cause: nil) ⇒ ApiError
Returns a new instance of ApiError.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/basecamp/api_error.rb', line 6 def initialize(, http_status: nil, hint: nil, retryable: false, cause: nil) super( code: ErrorCode::API, message: , hint: hint, http_status: http_status, retryable: retryable, cause: cause ) end |
Class Method Details
.from_status(status, message = nil) ⇒ ApiError
Creates an ApiError from an HTTP status code.
21 22 23 24 25 |
# File 'lib/basecamp/api_error.rb', line 21 def self.from_status(status, = nil) ||= "Request failed (HTTP #{status})" retryable = status >= 500 && status < 600 new(, http_status: status, retryable: retryable) end |