errors

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Unlicense Imports: 2 Imported by: 0 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorType

type ErrorType string

Error types for different categories of failures

const (
	ErrorTypeValidation    ErrorType = "validation"
	ErrorTypeStorage       ErrorType = "storage"
	ErrorTypeNetwork       ErrorType = "network"
	ErrorTypeComputation   ErrorType = "computation"
	ErrorTypeConfiguration ErrorType = "configuration"
	ErrorTypeTimeout       ErrorType = "timeout"
)

type StructuredError

type StructuredError struct {
	Type      ErrorType
	Operation string
	Message   string
	Cause     error
	Context   map[string]interface{}
	Stack     []uintptr
}

StructuredError provides rich error context

func New

func New(errType ErrorType, operation, message string) *StructuredError

New creates a new structured error

func NewComputationError

func NewComputationError(operation, message string) *StructuredError

NewComputationError creates a computation error

func NewConfigurationError

func NewConfigurationError(operation, message string) *StructuredError

NewConfigurationError creates a configuration error

func NewNetworkError

func NewNetworkError(operation, message string) *StructuredError

NewNetworkError creates a network error

func NewStorageError

func NewStorageError(operation, message string) *StructuredError

NewStorageError creates a storage error

func NewTimeoutError

func NewTimeoutError(operation, message string) *StructuredError

NewTimeoutError creates a timeout error

func NewValidationError

func NewValidationError(operation, message string) *StructuredError

NewValidationError creates a validation error

func Wrap

func Wrap(err error, errType ErrorType, operation, message string) *StructuredError

Wrap wraps an existing error with additional context

func WrapComputationError

func WrapComputationError(err error, operation, message string) *StructuredError

WrapComputationError wraps an error as a computation error

func WrapConfigurationError

func WrapConfigurationError(err error, operation, message string) *StructuredError

WrapConfigurationError wraps an error as a configuration error

func WrapNetworkError

func WrapNetworkError(err error, operation, message string) *StructuredError

WrapNetworkError wraps an error as a network error

func WrapStorageError

func WrapStorageError(err error, operation, message string) *StructuredError

WrapStorageError wraps an error as a storage error

func WrapTimeoutError

func WrapTimeoutError(err error, operation, message string) *StructuredError

WrapTimeoutError wraps an error as a timeout error

func WrapValidationError

func WrapValidationError(err error, operation, message string) *StructuredError

WrapValidationError wraps an error as a validation error

func (*StructuredError) Error

func (e *StructuredError) Error() string

Error implements the error interface

func (*StructuredError) Unwrap

func (e *StructuredError) Unwrap() error

Unwrap returns the underlying cause

func (*StructuredError) WithContext

func (e *StructuredError) WithContext(key string, value interface{}) *StructuredError

WithContext adds context information to an error

Jump to

Keyboard shortcuts

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