Documentation
¶
Overview ¶
Package errors provides a simplified, production-ready error handling system.
Index ¶
- Constants
- func GetExitCode(err error) int
- func Wrap(err error, message string) error
- type BaseError
- func New(message string) *BaseError
- func NewUsageError(message string, suggestions ...string) *BaseError
- func NewWithContext(component, operation, message string) *BaseError
- func WrapAttestor(err error, attestorID, phase string) *BaseError
- func WrapPipeline(err error, phase, attestorID string) *BaseError
- func WrapWithContext(err error, component, operation, message string) *BaseError
- type ValidationError
Constants ¶
const ( ExitSuccess = 0 ExitGeneralError = 1 ExitUsageError = 2 ExitValidationError = 3 ExitConfigError = 4 ExitRuntimeError = 5 )
Exit codes for different error scenarios.
Variables ¶
This section is empty.
Functions ¶
func GetExitCode ¶
GetExitCode extracts the exit code from any error.
Types ¶
type BaseError ¶
type BaseError struct {
Message string // What went wrong
Component string // Where it happened (e.g., "pipeline", "command", "attestor")
Operation string // What was being done (e.g., "validate", "execute", "sign")
Cause error // Underlying error if any
Suggestions []string // User-friendly suggestions (only shown in human output)
ExitCode int // CLI exit code
}
BaseError is our standard error with structured context.
func NewUsageError ¶
NewUsageError creates a usage error with suggestions.
func NewWithContext ¶
NewWithContext creates an error with context.
func WrapAttestor ¶
WrapAttestor wraps an error with attestor context.
func WrapPipeline ¶
WrapPipeline wraps an error with pipeline context.
func WrapWithContext ¶
WrapWithContext adds component/operation context to an error.
func (*BaseError) WithExitCode ¶
WithExitCode sets the exit code.
type ValidationError ¶
type ValidationError struct {
BaseError
Fields map[string][]string // field -> list of error messages
}
ValidationError aggregates field-level validation issues.
func NewValidator ¶
func NewValidator() *ValidationError
NewValidator creates a validation error collector.
func NewValidatorFor ¶
func NewValidatorFor(component string) *ValidationError
NewValidatorFor creates a validation error collector for a specific component.
func (*ValidationError) AddError ¶
func (v *ValidationError) AddError(field, message string)
AddError adds a field validation error.
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
Error returns the formatted error message.
func (*ValidationError) HasErrors ¶
func (v *ValidationError) HasErrors() bool
HasErrors checks if there are any validation errors.