Exception: Forem::ForemError
- Inherits:
-
StandardError
- Object
- StandardError
- Forem::ForemError
- Defined in:
- lib/forem/errors.rb
Overview
Base error class for all errors raised by the forem-ruby library.
Every error exposes the raw HTTP context (status code, body, headers) so callers can inspect the upstream response without re-issuing the request.
Direct Known Subclasses
APIConnectionError, APIError, AuthenticationError, AuthorizationError, ConflictError, InvalidRequestError, NotFoundError, RateLimitError
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
An optional machine-readable error code extracted from the API response body, or
nil. -
#http_body ⇒ String?
readonly
The raw HTTP response body as a string, or
nil. -
#http_headers ⇒ Hash?
readonly
A hash of HTTP response headers, or
nil. -
#http_status ⇒ Integer?
readonly
The HTTP status code returned by the server (e.g.
401,404,429), ornilif no HTTP response was received.
Instance Method Summary collapse
-
#initialize(message = nil, http_status: nil, http_body: nil, http_headers: nil, code: nil) ⇒ ForemError
constructor
Initialize a new ForemError.
Constructor Details
#initialize(message = nil, http_status: nil, http_body: nil, http_headers: nil, code: nil) ⇒ ForemError
Initialize a new ForemError.
41 42 43 44 45 46 47 |
# File 'lib/forem/errors.rb', line 41 def initialize( = nil, http_status: nil, http_body: nil, http_headers: nil, code: nil) @http_status = http_status @http_body = http_body @http_headers = http_headers @code = code super() end |
Instance Attribute Details
#code ⇒ String? (readonly)
Returns an optional machine-readable error code extracted
from the API response body, or nil.
31 32 33 |
# File 'lib/forem/errors.rb', line 31 def code @code end |
#http_body ⇒ String? (readonly)
Returns the raw HTTP response body as a string, or nil.
24 25 26 |
# File 'lib/forem/errors.rb', line 24 def http_body @http_body end |
#http_headers ⇒ Hash? (readonly)
Returns a hash of HTTP response headers, or nil.
27 28 29 |
# File 'lib/forem/errors.rb', line 27 def http_headers @http_headers end |
#http_status ⇒ Integer? (readonly)
Returns the HTTP status code returned by the server
(e.g. 401, 404, 429), or nil if no HTTP response was received.
21 22 23 |
# File 'lib/forem/errors.rb', line 21 def http_status @http_status end |