Documentation
¶
Overview ¶
Package errors defines common errors for the pre-commit system
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChecksFailed is returned when one or more checks fail ErrChecksFailed = errors.New("checks failed") // ErrNoChecksToRun is returned when no checks are configured to run ErrNoChecksToRun = errors.New("no checks to run") // ErrEnvFileNotFound is returned when .env.base cannot be found ErrEnvFileNotFound = errors.New("failed to find .env.base") // ErrRepositoryRootNotFound is returned when git repository root cannot be determined ErrRepositoryRootNotFound = errors.New("unable to determine repository root") // ErrToolNotFound is returned when a required tool is not available ErrToolNotFound = errors.New("required tool not found") // ErrFileNotFound is returned when a file is expected but not found ErrFileNotFound = errors.New("file not found") // ErrFileStillExists is returned when a file is expected to be deleted but still exists ErrFileStillExists = errors.New("file expected to be deleted but still exists") // ErrFmtIssues is returned when go fmt finds formatting issues ErrFmtIssues = errors.New("formatting issues found") // ErrLintingIssues is returned when linting finds issues ErrLintingIssues = errors.New("linting issues found") // ErrNotTidy is returned when go.mod/go.sum are not tidy ErrNotTidy = errors.New("go.mod or go.sum are not tidy") // ErrWhitespaceIssues is returned when whitespace issues are found ErrWhitespaceIssues = errors.New("whitespace issues found") // ErrEOFIssues is returned when EOF issues are found ErrEOFIssues = errors.New("EOF issues found") // ErrAIAttributionFound is returned when AI attribution is detected ErrAIAttributionFound = errors.New("AI attribution detected") // ErrToolExecutionFailed is returned when a tool execution fails ErrToolExecutionFailed = errors.New("tool execution failed") // ErrGracefulSkip is returned when a check is gracefully skipped ErrGracefulSkip = errors.New("check gracefully skipped") // ErrNilContext is returned when a nil context is provided ErrNilContext = errors.New("context cannot be nil") // ErrTimeout is returned when an operation times out ErrTimeout = errors.New("operation timed out") // Git-related errors ErrNotGitRepository = errors.New("not a git repository") ErrUnsupportedHookType = errors.New("unsupported hook type") ErrPreCommitDirNotExist = errors.New("pre-commit directory does not exist") ErrHookNotExecutable = errors.New("hook file is not executable") ErrHookMarkerMissing = errors.New("installed hook does not contain expected marker") )
Common errors
Functions ¶
This section is empty.
Types ¶
type CheckError ¶
type CheckError struct {
// Base error
Err error
// Human-readable message explaining what went wrong
Message string
// Actionable suggestion for how to fix the issue
Suggestion string
// Command that failed (if applicable)
Command string
// Raw output from the failed command
Output string
// Files that were being processed
Files []string
// Whether this error allows graceful degradation
CanSkip bool
}
CheckError represents an enhanced error with context and suggestions
func NewCheckError ¶
func NewCheckError(err error, message, suggestion string) *CheckError
NewCheckError creates a new CheckError
func NewGracefulSkipError ¶
func NewGracefulSkipError(reason string) *CheckError
NewGracefulSkipError creates an error for gracefully skipped checks
func NewToolExecutionError ¶
func NewToolExecutionError(command, output, suggestion string) *CheckError
NewToolExecutionError creates an error for tool execution failures
func NewToolNotFoundError ¶
func NewToolNotFoundError(tool, alternative string) *CheckError
NewToolNotFoundError creates an error for missing tools with graceful degradation
func (*CheckError) Is ¶
func (e *CheckError) Is(target error) bool
Is implements the error checking interface
func (*CheckError) Unwrap ¶
func (e *CheckError) Unwrap() error
Unwrap implements the error unwrapping interface
type TimeoutError ¶ added in v1.2.0
type TimeoutError struct {
// Base error
Err error
// Operation that timed out (e.g., "tool installation", "check execution")
Operation string
// Specific context (e.g., tool name, check name)
Context string
// Duration of the timeout that was applied
Timeout time.Duration
// Duration that elapsed before timeout
Elapsed time.Duration
// Configuration variable that can be used to adjust the timeout
ConfigVar string
// Suggested new timeout value
SuggestedTimeout time.Duration
}
TimeoutError represents a timeout error with detailed context
func NewCheckTimeoutError ¶ added in v1.2.0
func NewCheckTimeoutError(checkName string, timeout, elapsed time.Duration) *TimeoutError
NewCheckTimeoutError creates a timeout error specifically for check execution
func NewTimeoutError ¶ added in v1.2.0
func NewTimeoutError(operation, context string, timeout, elapsed time.Duration, configVar string) *TimeoutError
NewTimeoutError creates a new TimeoutError with context
func NewToolInstallTimeoutError ¶ added in v1.2.0
func NewToolInstallTimeoutError(toolName string, timeout, elapsed time.Duration) *TimeoutError
NewToolInstallTimeoutError creates a timeout error specifically for tool installation
func (*TimeoutError) Error ¶ added in v1.2.0
func (e *TimeoutError) Error() string
Error implements the error interface for TimeoutError
func (*TimeoutError) Is ¶ added in v1.2.0
func (e *TimeoutError) Is(target error) bool
Is implements the error checking interface for TimeoutError
func (*TimeoutError) Unwrap ¶ added in v1.2.0
func (e *TimeoutError) Unwrap() error
Unwrap implements the error unwrapping interface for TimeoutError