Exception: PoliPage::Error
- Inherits:
-
StandardError
- Object
- StandardError
- PoliPage::Error
- Defined in:
- lib/poli_page/errors.rb
Overview
Base for all SDK-raised errors. Inherits from ‘StandardError` so that `rescue => e` catches it (whereas inheriting from `Exception` would bypass the default rescue and surprise callers).
The rescue-friendly path is the class hierarchy (‘rescue PoliPage::AuthenticationError`); the predicate methods below are kept for spec parity with the Node SDK and for callers who want a single rescue clause backed by introspection.
Direct Known Subclasses
APIError, AuthenticationError, ConnectionError, DownloadError, GoneError, InternalError, InvalidOptionsError, NotFoundError, PermissionDeniedError, RateLimitError, TimeoutError, ValidationError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #auth_error? ⇒ Boolean
-
#initialize(message = nil, code:, status: nil, request_id: nil) ⇒ Error
constructor
A new instance of Error.
- #network_error? ⇒ Boolean
- #payload_status ⇒ Object
- #rate_limit_error? ⇒ Boolean
- #retryable? ⇒ Boolean
-
#to_payload ⇒ Object
Canonical wire payload for framework integrations: ‘message:, status:, request_id:`.
- #validation_error? ⇒ Boolean
Constructor Details
#initialize(message = nil, code:, status: nil, request_id: nil) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 |
# File 'lib/poli_page/errors.rb', line 15 def initialize( = nil, code:, status: nil, request_id: nil) super() @code = code @status = status @request_id = request_id end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/poli_page/errors.rb', line 13 def code @code end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
13 14 15 |
# File 'lib/poli_page/errors.rb', line 13 def request_id @request_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
13 14 15 |
# File 'lib/poli_page/errors.rb', line 13 def status @status end |
Instance Method Details
#auth_error? ⇒ Boolean
22 23 24 |
# File 'lib/poli_page/errors.rb', line 22 def auth_error? is_a?(AuthenticationError) || is_a?(PermissionDeniedError) end |
#network_error? ⇒ Boolean
34 35 36 |
# File 'lib/poli_page/errors.rb', line 34 def network_error? is_a?(ConnectionError) || is_a?(TimeoutError) end |
#payload_status ⇒ Object
59 60 61 |
# File 'lib/poli_page/errors.rb', line 59 def payload_status @status end |
#rate_limit_error? ⇒ Boolean
26 27 28 |
# File 'lib/poli_page/errors.rb', line 26 def rate_limit_error? is_a?(RateLimitError) end |
#retryable? ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/poli_page/errors.rb', line 38 def retryable? return true if network_error? return true if status && (status >= 500 || status == 429) false end |
#to_payload ⇒ Object
Canonical wire payload for framework integrations: ‘message:, status:, request_id:`. `status` surfaces 503 for connection failures, 504 for timeouts, the API HTTP status for status-bearing errors. The #status reader itself stays nil for transport-error instances — only the payload surfaces 503/504.
50 51 52 53 54 55 56 57 |
# File 'lib/poli_page/errors.rb', line 50 def to_payload { code: @code, message: , status: payload_status, request_id: @request_id } end |
#validation_error? ⇒ Boolean
30 31 32 |
# File 'lib/poli_page/errors.rb', line 30 def validation_error? is_a?(ValidationError) end |