Exception: Leash::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Leash::Error
- Defined in:
- lib/leash/errors.rb
Overview
Structured error type raised by every Leash SDK call site.
Mirrors ‘leash-sdk-ts/src/errors.ts` and Python’s ‘leash.errors.LeashError`. The `code` field is the stable machine-readable identifier consumers should switch on; `message` is the human-readable line; `action` and `see_also` are optional remediation hints.
Known codes (kept in sync with leash-sdk-ts):
- NO_API_KEY
- NO_REQUEST_SERVER_CONSTRUCT
- BROWSER_MODE_UNSUPPORTED
- UNAUTHORIZED
- NO_AUTH_CONTEXT
- INTEGRATION_NOT_ENABLED
- INTEGRATION_ERROR
- UPGRADE_REQUIRED
- PLAN_BLOCK
- CONNECTION_REQUIRED
- NETWORK_ERROR
- KEY_NOT_DECLARED
- INVALID_KEY
- SOURCE_RESYNC_FAILED
- ENV_FETCH_ERROR
Direct Known Subclasses
AuthError, ConnectionRequiredError, Leash::Env::NoApiKeyError, KeyNotDeclaredError, NetworkError, TokenExpiredError, UnauthorizedError, UpgradeRequiredError
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#see_also ⇒ Object
readonly
Returns the value of attribute see_also.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#connect_url ⇒ Object
Compatibility shim — the 0.3 surface exposed ‘connect_url`.
-
#initialize(message, code: nil, action: nil, see_also: nil, status: nil, cause: nil, connect_url: nil) ⇒ Error
constructor
A new instance of Error.
-
#message ⇒ Object
Override ‘message` to return our stored value — avoids Exception#message falling back to `to_s` and recursing infinitely.
- #to_s ⇒ Object
Constructor Details
#initialize(message, code: nil, action: nil, see_also: nil, status: nil, cause: nil, connect_url: nil) ⇒ Error
Returns a new instance of Error.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/leash/errors.rb', line 30 def initialize(, code: nil, action: nil, see_also: nil, status: nil, cause: nil, connect_url: nil) super() @message = @code = code @action = action @see_also = see_also @status = status @cause = cause @connect_url = connect_url end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
28 29 30 |
# File 'lib/leash/errors.rb', line 28 def action @action end |
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
28 29 30 |
# File 'lib/leash/errors.rb', line 28 def cause @cause end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
28 29 30 |
# File 'lib/leash/errors.rb', line 28 def code @code end |
#see_also ⇒ Object (readonly)
Returns the value of attribute see_also.
28 29 30 |
# File 'lib/leash/errors.rb', line 28 def see_also @see_also end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
28 29 30 |
# File 'lib/leash/errors.rb', line 28 def status @status end |
Instance Method Details
#connect_url ⇒ Object
Compatibility shim — the 0.3 surface exposed ‘connect_url`.
43 44 45 |
# File 'lib/leash/errors.rb', line 43 def connect_url @connect_url end |
#message ⇒ Object
Override ‘message` to return our stored value — avoids Exception#message falling back to `to_s` and recursing infinitely.
49 50 51 |
# File 'lib/leash/errors.rb', line 49 def @message end |
#to_s ⇒ Object
53 54 55 56 57 58 |
# File 'lib/leash/errors.rb', line 53 def to_s out = +"x #{@message}" out << "\n Fix: #{@action}" if @action out << "\n See: #{@see_also}" if @see_also out end |