errors

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errors provides structured CLI error types for Mush.

CLIError wraps errors with user-facing messages, hints, and exit codes to provide consistent, actionable error output across all commands.

Index

Constants

View Source
const (
	ExitSuccess   = 0  // Successful execution
	ExitGeneral   = 1  // General error
	ExitAuth      = 2  // Authentication error
	ExitNetwork   = 3  // Network/API error
	ExitConfig    = 4  // Configuration error
	ExitTimeout   = 5  // Execution timeout
	ExitExecution = 6  // Execution failure
	ExitUsage     = 64 // Command line usage error (BSD convention)
)

Exit codes for CLI errors.

Variables

This section is empty.

Functions

func As

func As(err error, target **CLIError) bool

As is a convenience function for errors.As with CLIError.

Types

type CLIError

type CLIError struct {
	// Message is the primary error message shown to the user.
	Message string

	// Hint provides actionable guidance on how to fix the error.
	Hint string

	// Cause is the underlying error, if any.
	Cause error

	// Code is the exit code for the CLI.
	Code int
}

CLIError represents a user-facing CLI error with actionable guidance.

func APIKeyEmpty

func APIKeyEmpty() *CLIError

APIKeyEmpty returns an error when the API key is empty.

func AuthFailed

func AuthFailed(cause error) *CLIError

AuthFailed returns an error for failed authentication.

func CannotPrompt

func CannotPrompt(envVar string) *CLIError

CannotPrompt returns an error when interactive prompts are unavailable.

func ClaudeExecutionFailed

func ClaudeExecutionFailed(exitCode int, stderr string) *CLIError

ClaudeExecutionFailed returns an error for Claude execution failures. It detects common error patterns and provides specific hints.

func ClaudeNotFound

func ClaudeNotFound() *CLIError

ClaudeNotFound returns an error when Claude CLI is not available.

func ClaudeSignalKilled

func ClaudeSignalKilled() *CLIError

ClaudeSignalKilled returns an error for interrupted execution.

func ConfigFailed

func ConfigFailed(operation string, cause error) *CLIError

ConfigFailed returns an error for configuration save failures.

func CredentialsInvalid

func CredentialsInvalid(cause error) *CLIError

CredentialsInvalid returns an error for invalid stored credentials.

func ExecutionTimedOut

func ExecutionTimedOut(timeout string, lastTools []string) *CLIError

ExecutionTimedOut returns an error for execution timeout with context.

func HabitatNotFound

func HabitatNotFound(name string) *CLIError

HabitatNotFound returns an error for an unknown habitat.

func HabitatRequired

func HabitatRequired() *CLIError

HabitatRequired returns an error when a habitat is required but not specified.

func InvalidAgentType

func InvalidAgentType(agentType string) *CLIError

InvalidAgentType returns an error for an unsupported agent type.

func JobNotFound

func JobNotFound(jobID string) *CLIError

JobNotFound returns an error for an unknown job.

func LinkRegistrationFailed

func LinkRegistrationFailed(cause error) *CLIError

LinkRegistrationFailed returns an error when link registration fails.

func New

func New(code int, message string) *CLIError

New creates a new CLIError with the given message and exit code.

func NoHabitats

func NoHabitats() *CLIError

NoHabitats returns an error when no habitats exist in the workspace.

func NoInstructionsForQueue

func NoInstructionsForQueue(queueName, queueSlug string) *CLIError

NoInstructionsForQueue returns an error when no active instruction exists for a queue.

func NoQueuesForHabitat

func NoQueuesForHabitat() *CLIError

NoQueuesForHabitat returns an error when a habitat has no eligible queues.

func NotAuthenticated

func NotAuthenticated() *CLIError

NotAuthenticated returns an error indicating missing credentials.

func QueueNotFound

func QueueNotFound(name string) *CLIError

QueueNotFound returns an error for an unknown queue.

func QueueRequired

func QueueRequired() *CLIError

QueueRequired returns an error when a queue is required but not specified.

func Wrap

func Wrap(code int, message string, cause error) *CLIError

Wrap wraps an existing error with a CLIError.

func (*CLIError) Error

func (e *CLIError) Error() string

Error implements the error interface.

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

Unwrap returns the underlying cause for errors.Is/As support.

func (*CLIError) WithHint

func (e *CLIError) WithHint(hint string) *CLIError

WithHint adds a hint to the error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL