Exception: Sadad::APIError
- Inherits:
-
SadadError
- Object
- StandardError
- SadadError
- Sadad::APIError
- Defined in:
- lib/sadad/errors.rb
Overview
APIError is raised when Sadad’s API returns an error response. These errors can be caused by various issues like invalid parameters, authentication failures, rate limiting, or internal server errors. The error includes:
-
message: Human readable error description
-
http_status: HTTP status code (e.g. 400, 401, 429, 500)
-
http_body: Raw response body from the API
-
error_code: Sadad-specific error code for more granular error handling
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
Attributes inherited from SadadError
#error, #http_body, #http_headers, #http_status, #json_body, #message
Instance Method Summary collapse
-
#initialize(message = nil, http_status: nil, http_body: nil, error_code: nil) ⇒ APIError
constructor
A new instance of APIError.
- #to_s ⇒ Object
Constructor Details
#initialize(message = nil, http_status: nil, http_body: nil, error_code: nil) ⇒ APIError
Returns a new instance of APIError.
49 50 51 52 |
# File 'lib/sadad/errors.rb', line 49 def initialize( = nil, http_status: nil, http_body: nil, error_code: nil) super(, http_status: http_status, http_body: http_body) @error_code = error_code end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
47 48 49 |
# File 'lib/sadad/errors.rb', line 47 def error_code @error_code end |
Instance Method Details
#to_s ⇒ Object
54 55 56 57 58 |
# File 'lib/sadad/errors.rb', line 54 def to_s error_code_string = @error_code ? "(Error Code #{@error_code}) " : "" status_string = @http_status ? "(Status #{@http_status}) " : "" "#{status_string}#{error_code_string}#{@message}" end |