Module: Browserctl::Error::SuggestedActions

Defined in:
lib/browserctl/error/suggested_actions.rb

Overview

Maps a stable error code (see Codes) to a short imperative sentence telling the operator (or AI agent) what to try next. Codes without an explicit entry fall back to a generic pointer to the error reference doc (added in PR #11 of v0.12).

Constant Summary collapse

DEFAULT =
"See docs/reference/errors.md for guidance."
TABLE =
{
  Codes::AUTH_REQUIRED =>
    "Run the suggested flow to refresh credentials, then retry.",
  Codes::SELECTOR_NOT_FOUND =>
    "Re-run snapshot to get fresh refs, then retry with a stable ref or selector.",
  Codes::STATE_EXPIRED =>
    "Re-save the state bundle (state save) or rotate it (state rotate).",
  Codes::SECRET_RESOLUTION_FAILED =>
    "Verify the secret resolver config and that the underlying secret exists.",
  Codes::DAEMON_UNREACHABLE =>
    "Start the daemon with 'browserctl daemon start', then retry.",
  Codes::PROTOCOL_MISMATCH =>
    "Upgrade browserctl to a version that supports this artifact's format version.",
  Codes::DOMAIN_NOT_ALLOWED =>
    "Add the domain to your policy allowlist or use an allowed URL.",
  Codes::KEY_NOT_FOUND =>
    "Verify the key was stored in this daemon session before fetching.",
  Codes::VALIDATION_FAILED =>
    "Check the argument or DSL usage against the documented contract, then retry.",
  Codes::INVALID_SELECTOR_REF =>
    "Pass either a CSS selector or a stable ref — one is required.",
  Codes::INVALID_STATE_NAME =>
    "Use only letters, digits, '_' or '-' (max 64 chars) for state names.",
  Codes::INVALID_DSL_USAGE =>
    "Check the workflow/flow DSL call against docs/reference/style-guide.md; " \
    "required blocks or arguments are missing.",
  Codes::INVALID_FORMAT_VERSION =>
    "Use a non-negative Integer for the format version header; see docs/reference/format-versions.md.",
  Codes::GENERIC => DEFAULT
}.freeze

Class Method Summary collapse

Class Method Details

.for(code) ⇒ String

Returns suggested action sentence; never nil.

Parameters:

  • code (String, nil)

    a SCREAMING_SNAKE code from Codes

Returns:

  • (String)

    suggested action sentence; never nil



47
48
49
# File 'lib/browserctl/error/suggested_actions.rb', line 47

def self.for(code)
  TABLE.fetch(code, DEFAULT)
end