Exception: Browserctl::AuthRequiredError

Inherits:
Error
  • Object
show all
Defined in:
lib/browserctl/errors.rb

Overview

Raised when the daemon detects that the current page needs authentication —the canonical signal that a workflow’s ‘load_state` should rotate the bound flow. Carries the bundle name (when a state load was in progress) and a suggested flow (from the bundle manifest) so callers can recover without additional lookups. The CLI maps this code to exit status 7.

Constant Summary collapse

AUTH_REQUIRED_EXIT_CODE =
7

Instance Attribute Summary collapse

Attributes inherited from Error

#code

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = "authentication required", state: nil, suggested_flow: nil, reason: nil) ⇒ AuthRequiredError

Returns a new instance of AuthRequiredError.



40
41
42
43
44
45
# File 'lib/browserctl/errors.rb', line 40

def initialize(msg = "authentication required", state: nil, suggested_flow: nil, reason: nil)
  super(msg)
  @state          = state
  @suggested_flow = suggested_flow
  @reason         = reason
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



38
39
40
# File 'lib/browserctl/errors.rb', line 38

def reason
  @reason
end

#stateObject (readonly)

Returns the value of attribute state.



38
39
40
# File 'lib/browserctl/errors.rb', line 38

def state
  @state
end

#suggested_flowObject (readonly)

Returns the value of attribute suggested_flow.



38
39
40
# File 'lib/browserctl/errors.rb', line 38

def suggested_flow
  @suggested_flow
end

Class Method Details

.default_codeObject



34
# File 'lib/browserctl/errors.rb', line 34

def self.default_code = "AUTH_REQUIRED"

Instance Method Details

#to_responseObject



47
48
49
50
51
52
53
54
55
# File 'lib/browserctl/errors.rb', line 47

def to_response
  {
    error: message,
    code: self.class.default_code,
    state: state,
    suggested_flow: suggested_flow,
    reason: reason
  }.compact
end