errors

package
v0.38.9 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRecoverable

func IsRecoverable(err error) bool

IsRecoverable checks if an error is recoverable

func NewContextualError

func NewContextualError(operation, resource, file string, cause error) error

NewContextualError creates a new contextual error

func NewDatabaseError

func NewDatabaseError(operation, table string, err error) error

func NewFileOperationError

func NewFileOperationError(path, operation string, err error) error

func NewGeneratorError

func NewGeneratorError(operation, resource string, err error) error

func NewSpecificFileOperationError

func NewSpecificFileOperationError(path, operation string, err error) error

func NewTemplateError

func NewTemplateError(templateName, operation string, err error) error

func NewValidationError

func NewValidationError(field, value, reason string, cause error) error

func WrapDatabaseError

func WrapDatabaseError(err error, operation, table string) error

WrapDatabaseError wraps a database error

func WrapError

func WrapError(err error, ctx ErrorContext) error

WrapError wraps an error with context

func WrapErrorWithCaller

func WrapErrorWithCaller(err error, ctx ErrorContext) error

WrapErrorWithCaller wraps an error with context and caller information

func WrapFileError

func WrapFileError(err error, operation, filePath string) error

WrapFileError wraps a file operation error

func WrapGenerationError

func WrapGenerationError(err error, operation, resource string) error

WrapGenerationError wraps a generation error

func WrapTemplateError

func WrapTemplateError(err error, operation, templateName string) error

WrapTemplateError wraps a template error

func WrapValidationError

func WrapValidationError(err error, field, value string) error

WrapValidationError wraps a validation error

Types

type ContextualError

type ContextualError struct {
	Context *ErrorContext `json:"context"`
	Cause   error         `json:"cause"`
}

ContextualError provides enhanced error information with context

func (*ContextualError) Error

func (e *ContextualError) Error() string

Error implements the error interface

func (*ContextualError) Unwrap

func (e *ContextualError) Unwrap() error

Unwrap returns the underlying cause

type DatabaseError

type DatabaseError struct {
	Operation string
	Table     string
	Cause     error
}

func (*DatabaseError) Error

func (e *DatabaseError) Error() string

func (*DatabaseError) Unwrap

func (e *DatabaseError) Unwrap() error

type DefaultErrorRecovery

type DefaultErrorRecovery struct{}

DefaultErrorRecovery provides basic error recovery strategies

func (*DefaultErrorRecovery) CanRecover

func (der *DefaultErrorRecovery) CanRecover(err error) bool

CanRecover determines if an error is recoverable

func (*DefaultErrorRecovery) Recover

func (der *DefaultErrorRecovery) Recover(err error) error

Recover attempts to recover from an error

type ErrorBuilder

type ErrorBuilder struct {
	// contains filtered or unexported fields
}

ErrorBuilder provides a fluent interface for building contextual errors

func NewErrorBuilder

func NewErrorBuilder() *ErrorBuilder

NewErrorBuilder creates a new error builder

func (*ErrorBuilder) Detail

func (eb *ErrorBuilder) Detail(key string, value interface{}) *ErrorBuilder

Detail adds a detail

func (*ErrorBuilder) File

func (eb *ErrorBuilder) File(file string) *ErrorBuilder

File sets the file

func (*ErrorBuilder) New

func (eb *ErrorBuilder) New(message string) error

New creates a new error with the built context

func (*ErrorBuilder) Operation

func (eb *ErrorBuilder) Operation(operation string) *ErrorBuilder

Operation sets the operation

func (*ErrorBuilder) Resource

func (eb *ErrorBuilder) Resource(resource string) *ErrorBuilder

Resource sets the resource

func (*ErrorBuilder) Wrap

func (eb *ErrorBuilder) Wrap(err error) error

Wrap wraps an error with the built context

type ErrorContext

type ErrorContext struct {
	Operation string                 `json:"operation"`
	Resource  string                 `json:"resource"`
	File      string                 `json:"file"`
	Details   map[string]interface{} `json:"details"`
}

ErrorContext provides context for error wrapping

func NewErrorContext

func NewErrorContext(operation, resource, file string) *ErrorContext

NewErrorContext creates a new error context

func (*ErrorContext) WithCaller

func (ec *ErrorContext) WithCaller(skip int) *ErrorContext

WithCaller adds caller information to the error context

func (*ErrorContext) WithDetail

func (ec *ErrorContext) WithDetail(key string, value interface{}) *ErrorContext

WithDetail adds a detail to the error context

type ErrorRecovery

type ErrorRecovery interface {
	Recover(err error) error
	CanRecover(err error) bool
}

ErrorRecovery defines strategies for error recovery

type FileOperationError

type FileOperationError struct {
	Path      string
	Operation string
	Cause     error
}

func (*FileOperationError) Error

func (e *FileOperationError) Error() string

func (*FileOperationError) Unwrap

func (e *FileOperationError) Unwrap() error

type GenerationError

type GenerationError struct {
	Operation string
	Resource  string
	File      string
	Cause     error
}

func (*GenerationError) Error

func (e *GenerationError) Error() string

func (*GenerationError) Unwrap

func (e *GenerationError) Unwrap() error

type TemplateError

type TemplateError struct {
	TemplateName string
	Operation    string
	Cause        error
}

func (*TemplateError) Error

func (e *TemplateError) Error() string

func (*TemplateError) Unwrap

func (e *TemplateError) Unwrap() error

type ValidationError

type ValidationError struct {
	Field  string
	Value  string
	Reason string
	Cause  error
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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