errors

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ColorReset   = "\033[0m"
	ColorRed     = "\033[31m"
	ColorYellow  = "\033[33m"
	ColorMagenta = "\033[35m"
	ColorCyan    = "\033[36m"
	ColorGray    = "\033[90m"
	ColorBold    = "\033[1m"
)

ANSI color codes (no external deps)

Variables

View Source
var (
	ErrValidation   = errors.New("validation error")
	ErrNotFound     = errors.New("not found")
	ErrInternal     = errors.New("internal error")
	ErrInvalidInput = errors.New("invalid input")
)

Common error categories

Functions

This section is empty.

Types

type DataDumper

type DataDumper interface {
	Dump(v interface{}) string
}

DataDumper abstracts pretty-printing of arbitrary Go values

type DefaultStringFormatter

type DefaultStringFormatter struct{}

DefaultStringFormatter uses fmt package (infrastructure adapter)

func (*DefaultStringFormatter) Format

func (f *DefaultStringFormatter) Format(format string, args ...interface{}) string

type DomainError

type DomainError struct {
	Category    error
	Code        string
	Message     string
	Blame       string
	Suggestions []string
	Details     map[string]interface{}
	Cause       error
}

DomainError provides structured error information with Elm-style guidance

func (*DomainError) Error

func (e *DomainError) Error() string

func (*DomainError) PrettyError

func (e *DomainError) PrettyError(useColors bool, dumper DataDumper) string

PrettyError renders the error with ANSI colors and readable dumps

func (*DomainError) Unwrap

func (e *DomainError) Unwrap() error

type DomainErrorFactory

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

DomainErrorFactory builds common AutoPDF errors with context

func NewDomainErrorFactory

func NewDomainErrorFactory(formatter StringFormatter) *DomainErrorFactory

func (*DomainErrorFactory) CleanupFailed

func (f *DomainErrorFactory) CleanupFailed(pdfPath string, cause error) error

func (*DomainErrorFactory) EngineInvalid

func (f *DomainErrorFactory) EngineInvalid(engine string) error

func (*DomainErrorFactory) LaTeXCompilationFailed

func (f *DomainErrorFactory) LaTeXCompilationFailed(outputPath string, cause error) error

func (*DomainErrorFactory) OutputPathEmpty

func (f *DomainErrorFactory) OutputPathEmpty() error

func (*DomainErrorFactory) PDFConversionFailed

func (f *DomainErrorFactory) PDFConversionFailed(pdfPath string, cause error) error

func (*DomainErrorFactory) PassesInvalid

func (f *DomainErrorFactory) PassesInvalid(passes int) error

func (*DomainErrorFactory) TemplatePathEmpty

func (f *DomainErrorFactory) TemplatePathEmpty() error

func (*DomainErrorFactory) TemplateProcessingFailed

func (f *DomainErrorFactory) TemplateProcessingFailed(templatePath string, cause error) error

func (*DomainErrorFactory) VariableMissing

func (f *DomainErrorFactory) VariableMissing(variable, template string) error

type ErrorBuilder

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

ErrorBuilder builds DomainError instances fluently

func NewInternalError

func NewInternalError(code, message string) *ErrorBuilder

func NewInvalidInputError

func NewInvalidInputError(code, message string) *ErrorBuilder

func NewNotFoundError

func NewNotFoundError(code, message string) *ErrorBuilder

func NewValidationError

func NewValidationError(code, message string) *ErrorBuilder

func (*ErrorBuilder) Build

func (b *ErrorBuilder) Build() error

func (*ErrorBuilder) WithBlame

func (b *ErrorBuilder) WithBlame(blame string) *ErrorBuilder

func (*ErrorBuilder) WithCause

func (b *ErrorBuilder) WithCause(cause error) *ErrorBuilder

func (*ErrorBuilder) WithDetail

func (b *ErrorBuilder) WithDetail(key string, value interface{}) *ErrorBuilder

func (*ErrorBuilder) WithDetails

func (b *ErrorBuilder) WithDetails(details map[string]interface{}) *ErrorBuilder

func (*ErrorBuilder) WithSuggestions

func (b *ErrorBuilder) WithSuggestions(suggestions ...string) *ErrorBuilder

type JSONDumper

type JSONDumper struct{}

JSONDumper is a zero-dependency dumper using json.MarshalIndent

func (JSONDumper) Dump

func (d JSONDumper) Dump(v interface{}) string

type PrettyPrinter

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

PrettyPrinter formats errors with ANSI colors and readable dumps

func NewPrettyPrinter

func NewPrettyPrinter(useColors bool, dumper DataDumper) *PrettyPrinter

func (*PrettyPrinter) FormatError

func (pp *PrettyPrinter) FormatError(err *DomainError) string

type StringFormatter

type StringFormatter interface {
	Format(format string, args ...interface{}) string
}

StringFormatter abstracts string formatting operations (DIP compliance)

Jump to

Keyboard shortcuts

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