errors

package
v0.0.0-...-f318275 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// System errors
	CodeUnknown       = "unknown_error"
	CodeInitFailed    = "init_failed"
	CodeConfigError   = "config_error"
	CodeRuntimeError  = "runtime_error"
	CodeTimeoutError  = "timeout_error"
	CodeValidateError = "validate_error"
	CodeVersionError  = "version_error"

	// Domain errors
	CodeGitError      = "git_error"
	CodeLLMError      = "llm_error"
	CodeInputError    = "input_error"
	CodeTemplateError = "template_error"
	CodeNoChanges     = "no_changes"
	CodeLLMGenFailed  = "llm_gen_failed"
	CodeIOError       = "io_error"
)

Error codes - Layer 1

View Source
const (
	// Configuration contexts
	ContextConfigNotFound        = "config file not found"
	ContextConfigUnmarshal       = "failed to unmarshal configuration"
	ContextInvalidLogLevel       = "invalid log level specified"
	ContextInvalidTimeFormat     = "invalid time format specified"
	ContextMissingFunctionConfig = "required function configuration missing"
	ContextMissingPrompt         = "missing %s prompt for function: %s" // system/user
	ContextMissingAPIKey         = "API key required for %s provider"

	// Git contexts
	ContextNoChanges            = "no changes staged for commit - use 'git add' to stage files"
	ContextGitUserNotConfigured = "git user not configured - run: git config --global user.name '<name>' " +
		"&& git config --global user.email '<email>'"
	ContextGitRepoOpen          = "failed to open git repository"
	ContextGitWorkTree          = "failed to get git worktree"
	ContextGitStatus            = "failed to get git status"
	ContextGitCommit            = "failed to create git commit"
	ContextGitBranch            = "failed to get current branch"
	ContextGitDiff              = "failed to get file diff"
	ContextGitIgnore            = "failed to read gitignore patterns"
	ContextGitConfigInvalidMode = "invalid git config mode"
	ContextGitConfigReadError   = "failed to read git config"
	ContextGitConfigWriteError  = "failed to write git config"
	ContextGitSigningDisabled   = "git commit signing is disabled"
	ContextGitSigningFailed     = "failed to sign git commit"
	ContextGitSigningKey        = "failed to get git signing key"
	ContextGitSigningConfig     = "failed to read git signing configuration"
	ContextGitFileDeleted       = "file has been deleted: %s"
	ContextGitFileRenamed       = "file has been renamed from %s to %s"
	ContextGitFileNotFound      = "file not found in repository: %s"
	ContextGitFileStatus        = "file status: %s"
	ContextGitDiffTruncated     = "diff truncated at %d lines"

	// LLM contexts
	ContextLLMRequest         = "failed to make LLM request"
	ContextLLMResponse        = "failed to decode LLM response"
	ContextLLMNoChoices       = "no choices in LLM response"
	ContextLLMEmptyResponse   = "empty response from LLM function"
	ContextLLMInvalidResponse = "invalid response format from LLM"
	ContextLLMRateLimit       = "rate limit exceeded"
	ContextLLMTimeout         = "LLM request timed out"
	ContextLLMGeneration      = "failed to generate commit message: %s"
	ContextLLMRetryMessage    = "LLM is struggling to generate a valid commit message - " +
		"try running the command again, make the changes smaller, or commit manually"
	// Command contexts
	ContextNoCommand      = "no command specified"
	ContextInvalidCommand = "unknown command: %s"
	ContextNotImplemented = "command not yet implemented"
	ContextCommandFailed  = "command execution failed"

	// File operation contexts
	ContextFileCreate  = "failed to create file: %s"
	ContextFileRead    = "failed to read file: %s"
	ContextFileWrite   = "failed to write file: %s"
	ContextFileDelete  = "failed to delete file: %s"
	ContextFileRestore = "failed to restore file: %s"
	ContextDirCreate   = "failed to create directory: %s"

	// Version bump contexts
	ContextVersionAnalyze    = "failed to analyze version changes"
	ContextVersionParse      = "failed to parse version suggestion"
	ContextVersionInvalid    = "invalid version format"
	ContextVersionPreRelease = "invalid pre-release format: %s"
	ContextVersionBumpType   = "invalid bump type: %s"
	ContextVersionPropose    = "failed to propose version change"
	ContextVersionApply      = "failed to apply version change"
)

Error contexts - Layer 4

Variables

View Source
var (
	Is = errors.Is
	As = errors.As
)

Use standard errors.Is and errors.As directly

View Source
var (
	ErrNotFound          = errors.New("not found")
	ErrInvalidInput      = errors.New("invalid input")
	ErrUnauthorized      = errors.New("unauthorized")
	ErrInternal          = errors.New("internal error")
	ErrLLMStatus         = errors.New("LLM status error")
	ErrNilContext        = errors.New("context cannot be nil")
	ErrNilFunction       = errors.New("function definition cannot be nil")
	ErrInvalidConfig     = errors.New("invalid configuration")
	ErrTimeout           = errors.New("timeout")
	ErrIO                = errors.New("I/O error")
	ErrRateLimitExceeded = errors.New("rate limit exceeded")
	ErrInvalidResponse   = errors.New("invalid response")
)

Base errors - Layer 3

Functions

func FormatContext

func FormatContext(format string, args ...interface{}) string

Helper functions

func GetCode

func GetCode(err error) string

func GetMessage

func GetMessage(code string) string

Error information retrieval

func IsConfigFileNotFound

func IsConfigFileNotFound(err error) bool

Error type checking

func IsGitConfigError

func IsGitConfigError(err error) bool

func IsGitFileOperation

func IsGitFileOperation(err error) bool

func IsGitSigningError

func IsGitSigningError(err error) bool

func IsLLMError

func IsLLMError(err error) bool

func IsNoChanges

func IsNoChanges(err error) bool

func IsTimeoutError

func IsTimeoutError(err error) bool

func IsVersionBumpTypeError

func IsVersionBumpTypeError(err error) bool

func IsVersionError

func IsVersionError(err error) bool

func IsVersionPreReleaseError

func IsVersionPreReleaseError(err error) bool

func New

func New(code string) error

Error creation and wrapping

func Wrap

func Wrap(code string, err error) error

func WrapWithContext

func WrapWithContext(code string, err error, context string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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