Exception: Browserctl::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Browserctl::Error
- Defined in:
- lib/browserctl/errors.rb,
lib/browserctl/error/codes.rb,
lib/browserctl/error/exit_codes.rb,
lib/browserctl/error/suggested_actions.rb
Overview
Base error class for all browserctl daemon errors. Subclasses carry a machine-readable ‘code` that appears in wire responses. The canonical enum of stable codes lives in Codes; the sweep that retrofits every raise to use those codes lands in a later v0.12 PR.
Direct Known Subclasses
AuthRequiredError, BrowserNotFound, DaemonUnavailableError, DomainNotAllowed, KeyNotFound, PageNotFound, PathNotAllowed, ProtocolMismatch, RefNotFound, SelectorNotFound, State::Bundle::BundleError, State::Transport::TransportError, TimeoutError, WorkflowError
Defined Under Namespace
Modules: Codes, ExitCodes, SuggestedActions
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
machine-readable error code.
-
#context ⇒ Hash
readonly
free-form structured fields (selector, path, …).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(msg = nil, code: self.class.default_code, context: {}) ⇒ Error
constructor
A new instance of Error.
-
#to_payload ⇒ Hash{Symbol => Object}
Returns the canonical structured payload emitted on the daemon wire and on CLI stderr.
Constructor Details
#initialize(msg = nil, code: self.class.default_code, context: {}) ⇒ Error
Returns a new instance of Error.
20 21 22 23 24 |
# File 'lib/browserctl/errors.rb', line 20 def initialize(msg = nil, code: self.class.default_code, context: {}) @code = code @context = context || {} super(msg) end |
Instance Attribute Details
#code ⇒ String (readonly)
machine-readable error code
15 16 17 |
# File 'lib/browserctl/errors.rb', line 15 def code @code end |
#context ⇒ Hash (readonly)
free-form structured fields (selector, path, …)
15 16 17 |
# File 'lib/browserctl/errors.rb', line 15 def context @context end |
Class Method Details
.default_code ⇒ Object
16 |
# File 'lib/browserctl/errors.rb', line 16 def self.default_code = "error" |
Instance Method Details
#to_payload ⇒ Hash{Symbol => Object}
Returns the canonical structured payload emitted on the daemon wire and on CLI stderr. Shape is stable across releases — agents branch on ‘code` without parsing prose.
30 31 32 33 34 35 36 37 |
# File 'lib/browserctl/errors.rb', line 30 def to_payload { code: code, message: , context: context, suggested_action: SuggestedActions.for(code) } end |