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, #context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#to_payload

Constructor Details

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

Returns a new instance of AuthRequiredError.



62
63
64
65
66
67
# File 'lib/browserctl/errors.rb', line 62

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.



60
61
62
# File 'lib/browserctl/errors.rb', line 60

def reason
  @reason
end

#stateObject (readonly)

Returns the value of attribute state.



60
61
62
# File 'lib/browserctl/errors.rb', line 60

def state
  @state
end

#suggested_flowObject (readonly)

Returns the value of attribute suggested_flow.



60
61
62
# File 'lib/browserctl/errors.rb', line 60

def suggested_flow
  @suggested_flow
end

Class Method Details

.default_codeObject



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

def self.default_code = Codes::AUTH_REQUIRED

Instance Method Details

#to_responseObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/browserctl/errors.rb', line 69

def to_response
  {
    error: message,
    code: self.class.default_code,
    state: state,
    suggested_flow: suggested_flow,
    reason: reason,
    context: { state: state, suggested_flow: suggested_flow, reason: reason }.compact,
    suggested_action: SuggestedActions.for(self.class.default_code)
  }.compact
end