Exception: SignWell::ApiStatusError
- Defined in:
- lib/signwell_sdk/api_error.rb
Overview
Raised when the API returns a non-success HTTP status code. Use ApiStatusError.for to construct the appropriate subclass.
Direct Known Subclasses
AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError
Instance Attribute Summary
Attributes inherited from ApiError
#body, #code, #response_body, #response_headers
Class Method Summary collapse
-
.for(code:, response_headers: nil, response_body: nil, message: nil) ⇒ ApiStatusError
Factory method that returns the appropriate error subclass based on the HTTP status code.
Methods inherited from ApiError
Constructor Details
This class inherits a constructor from SignWell::ApiError
Class Method Details
.for(code:, response_headers: nil, response_body: nil, message: nil) ⇒ ApiStatusError
Factory method that returns the appropriate error subclass based on the HTTP status code.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/signwell_sdk/api_error.rb', line 80 def self.for(code:, response_headers: nil, response_body: nil, message: nil) klass = case code when 400 then BadRequestError when 401 then AuthenticationError when 403 then PermissionDeniedError when 404 then NotFoundError when 409 then ConflictError when 422 then UnprocessableEntityError when 429 then RateLimitError else code >= 500 ? InternalServerError : ApiStatusError end klass.new( code: code, response_headers: response_headers, response_body: response_body, message: ) end |