Documentation
¶
Index ¶
- func CleaningError(message string) error
- func ConfigLoadError(message string) error
- func ConfigSaveError(message string) error
- func ConfigValidateError(message string) error
- func IsNixAvailable() bool
- func NixCommandError(message string) error
- func ValidationError(field, value, expected string) error
- type CleanWizardError
- func HandleCommandError(cmd *exec.Cmd, err error) *CleanWizardError
- func HandleConfigError(operation string, err error) *CleanWizardError
- func HandleNixNotAvailable(operation string) *CleanWizardError
- func HandleValidationError(operation string, err error) *CleanWizardError
- func HandleValidationErrorWithDetails(operation, field string, value any, reason string) *CleanWizardError
- func NewError(code ErrorCode, message string) *CleanWizardError
- func NewErrorWithDetails(code ErrorCode, message string, details *ErrorDetails) *CleanWizardError
- func NewErrorWithLevel(code ErrorCode, level ErrorLevel, message string) *CleanWizardError
- func WrapError(err error, code ErrorCode, operation string) *CleanWizardError
- func (e *CleanWizardError) Error() string
- func (e *CleanWizardError) IsErrorCode(code ErrorCode) bool
- func (e *CleanWizardError) IsLevel(level ErrorLevel) bool
- func (e *CleanWizardError) IsRetryable() bool
- func (e *CleanWizardError) IsUserFriendly() bool
- func (e *CleanWizardError) Log()
- func (e *CleanWizardError) Unwrap() error
- func (e *CleanWizardError) WithDetail(key string, value any) *CleanWizardError
- func (e *CleanWizardError) WithLevel(level ErrorLevel) *CleanWizardError
- func (e *CleanWizardError) WithOperation(operation string) *CleanWizardError
- type ErrorCode
- type ErrorDetails
- type ErrorLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleaningError ¶
CleaningError creates cleaning operation error.
func ConfigLoadError ¶
ConfigLoadError creates config loading error.
func ConfigSaveError ¶
ConfigSaveError creates config saving error.
func ConfigValidateError ¶
ConfigValidateError creates config validation error.
func IsNixAvailable ¶
func IsNixAvailable() bool
IsNixAvailable checks if Nix is available on the system.
func NixCommandError ¶
NixCommandError creates nix command error.
func ValidationError ¶
ValidationError creates validation error.
Types ¶
type CleanWizardError ¶
type CleanWizardError struct {
Code ErrorCode
Level ErrorLevel
Message string
Operation string
Details *ErrorDetails `json:"details,omitempty"`
Timestamp time.Time
Stack string
}
CleanWizardError represents structured error with context.
func HandleCommandError ¶
func HandleCommandError(cmd *exec.Cmd, err error) *CleanWizardError
HandleCommandError standardizes command execution errors.
func HandleConfigError ¶
func HandleConfigError(operation string, err error) *CleanWizardError
HandleConfigError standardizes configuration errors.
func HandleNixNotAvailable ¶
func HandleNixNotAvailable(operation string) *CleanWizardError
HandleNixNotAvailable standardizes Nix availability errors.
func HandleValidationError ¶
func HandleValidationError(operation string, err error) *CleanWizardError
HandleValidationError standardizes validation errors.
func HandleValidationErrorWithDetails ¶
func HandleValidationErrorWithDetails(operation, field string, value any, reason string) *CleanWizardError
HandleValidationErrorWithDetails standardizes validation errors with detailed context.
func NewError ¶
func NewError(code ErrorCode, message string) *CleanWizardError
NewError creates new CleanWizardError.
func NewErrorWithDetails ¶
func NewErrorWithDetails(code ErrorCode, message string, details *ErrorDetails) *CleanWizardError
NewErrorWithDetails creates new CleanWizardError with context details.
func NewErrorWithLevel ¶
func NewErrorWithLevel(code ErrorCode, level ErrorLevel, message string) *CleanWizardError
NewErrorWithLevel creates new CleanWizardError with custom level.
func WrapError ¶
func WrapError(err error, code ErrorCode, operation string) *CleanWizardError
WrapError wraps existing error with CleanWizardError context.
func (*CleanWizardError) Error ¶
func (e *CleanWizardError) Error() string
Error implements error interface.
func (*CleanWizardError) IsErrorCode ¶
func (e *CleanWizardError) IsErrorCode(code ErrorCode) bool
IsErrorCode checks if error matches specific error code.
func (*CleanWizardError) IsLevel ¶
func (e *CleanWizardError) IsLevel(level ErrorLevel) bool
IsLevel checks if error matches specific level.
func (*CleanWizardError) IsRetryable ¶
func (e *CleanWizardError) IsRetryable() bool
IsRetryable checks if error is retryable.
func (*CleanWizardError) IsUserFriendly ¶
func (e *CleanWizardError) IsUserFriendly() bool
IsUserFriendly checks if error is safe to show to users.
func (*CleanWizardError) Log ¶
func (e *CleanWizardError) Log()
Log logs the error with appropriate level.
func (*CleanWizardError) Unwrap ¶
func (e *CleanWizardError) Unwrap() error
Unwrap returns the underlying error for compatibility with Go 1.13+ error wrapping.
func (*CleanWizardError) WithDetail ¶
func (e *CleanWizardError) WithDetail(key string, value any) *CleanWizardError
WithDetail adds single detail to error.
func (*CleanWizardError) WithLevel ¶
func (e *CleanWizardError) WithLevel(level ErrorLevel) *CleanWizardError
WithLevel sets error level.
func (*CleanWizardError) WithOperation ¶
func (e *CleanWizardError) WithOperation(operation string) *CleanWizardError
WithOperation adds operation context to error.
type ErrorCode ¶
type ErrorCode int
ErrorCode represents standardized error codes.
const ( // General errors. ErrUnknown ErrorCode = iota ErrInvalidInput ErrNotFound ErrPermissionDenied ErrTimeout // Configuration errors. ErrConfigLoad ErrConfigSave ErrConfigValidation // Nix-specific errors. ErrNixNotAvailable ErrNixCommandFailed ErrNixStoreCorrupted // Cleaning errors. ErrCleaningFailed ErrCleaningTimeout ErrCleanupRollback )
type ErrorDetails ¶
type ErrorDetails struct {
Field string `json:"field,omitempty"`
Value string `json:"value,omitempty"`
Expected string `json:"expected,omitempty"`
Actual string `json:"actual,omitempty"`
Operation string `json:"operation,omitempty"`
FilePath string `json:"file_path,omitempty"`
LineNumber int `json:"line_number,omitempty"`
RetryCount int `json:"retry_count,omitempty"`
Duration string `json:"duration,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ErrorDetails represents strongly-typed error context information.
type ErrorLevel ¶
type ErrorLevel int
ErrorLevel represents severity level of errors.
const ( // Error levels. LevelDebug ErrorLevel = iota LevelInfo LevelWarn LevelError LevelFatal LevelPanic )
func (ErrorLevel) LogLevel ¶
func (e ErrorLevel) LogLevel() string
LogLevel returns the corresponding logrus level.
func (ErrorLevel) String ¶
func (e ErrorLevel) String() string
String returns string representation of error level.