errors

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors provides typed errors for staghorn.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode string

ErrorCode identifies the type of error.

const (
	ErrConfigNotFound      ErrorCode = "CONFIG_NOT_FOUND"
	ErrConfigInvalid       ErrorCode = "CONFIG_INVALID"
	ErrGitHubAuthFailed    ErrorCode = "GITHUB_AUTH_FAILED"
	ErrGitHubFetchFailed   ErrorCode = "GITHUB_FETCH_FAILED"
	ErrCacheNotFound       ErrorCode = "CACHE_NOT_FOUND"
	ErrCacheStale          ErrorCode = "CACHE_STALE"
	ErrNoNetwork           ErrorCode = "NO_NETWORK"
	ErrProjectNotFound     ErrorCode = "PROJECT_NOT_FOUND"
	ErrInvalidRepo         ErrorCode = "INVALID_REPO"
	ErrAnthropicAuthFailed ErrorCode = "ANTHROPIC_AUTH_FAILED"
	ErrOptimizationFailed  ErrorCode = "OPTIMIZATION_FAILED"
	ErrValidationFailed    ErrorCode = "VALIDATION_FAILED"
)

type StaghornError

type StaghornError struct {
	Code    ErrorCode
	Message string
	Hint    string
	Cause   error
}

StaghornError represents a typed error with user-friendly hints.

func AnthropicAuthFailed added in v0.6.0

func AnthropicAuthFailed() *StaghornError

AnthropicAuthFailed returns an error for missing Anthropic API key.

func CacheNotFound

func CacheNotFound(repo string) *StaghornError

CacheNotFound returns an error when cache doesn't exist.

func ConfigInvalid

func ConfigInvalid(reason string) *StaghornError

ConfigInvalid returns an error for invalid config.

func ConfigNotFound

func ConfigNotFound(path string) *StaghornError

ConfigNotFound returns an error for missing config file.

func GitHubAuthFailed

func GitHubAuthFailed(cause error) *StaghornError

GitHubAuthFailed returns an error for authentication failures.

func GitHubFetchFailed

func GitHubFetchFailed(repo string, cause error) *StaghornError

GitHubFetchFailed returns an error for fetch failures.

func InvalidRepo

func InvalidRepo(repo string) *StaghornError

InvalidRepo returns an error for malformed repo strings.

func New

func New(code ErrorCode, message, hint string) *StaghornError

New creates a new StaghornError.

func OptimizationFailed added in v0.6.0

func OptimizationFailed(reason string, cause error) *StaghornError

OptimizationFailed returns an error when optimization fails.

func ValidationFailed added in v0.6.0

func ValidationFailed(missing []string) *StaghornError

ValidationFailed returns an error when optimized content fails validation.

func Wrap

func Wrap(code ErrorCode, message, hint string, cause error) *StaghornError

Wrap creates a new StaghornError wrapping an existing error.

func (*StaghornError) Error

func (e *StaghornError) Error() string

func (*StaghornError) Unwrap

func (e *StaghornError) Unwrap() error

Jump to

Keyboard shortcuts

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