errors

package
v1.18.1-qos Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides common error types and utilities for the Lux node.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Database errors
	ErrNotFound     = errors.New("not found")
	ErrClosed       = errors.New("closed")
	ErrCorrupted    = errors.New("corrupted")
	ErrReadOnly     = errors.New("read only")
	ErrDiskFull     = errors.New("disk full")
	ErrInvalidKey   = errors.New("invalid key")
	ErrInvalidValue = errors.New("invalid value")

	// Network errors
	ErrTimeout          = errors.New("timeout")
	ErrConnectionClosed = errors.New("connection closed")
	ErrConnectionReset  = errors.New("connection reset")
	ErrNoRoute          = errors.New("no route to host")
	ErrRefused          = errors.New("connection refused")
	ErrNetworkDown      = errors.New("network down")

	// Validation errors
	ErrInvalidInput     = errors.New("invalid input")
	ErrInvalidSignature = errors.New("invalid signature")
	ErrInvalidChecksum  = errors.New("invalid checksum")
	ErrInvalidFormat    = errors.New("invalid format")
	ErrMissingField     = errors.New("missing required field")
	ErrFieldTooLarge    = errors.New("field exceeds maximum size")

	// State errors
	ErrNotInitialized = errors.New("not initialized")
	ErrAlreadyExists  = errors.New("already exists")
	ErrNotSupported   = errors.New("not supported")
	ErrDeprecated     = errors.New("deprecated")
	ErrConflict       = errors.New("conflict")
	ErrCanceled       = errors.New("canceled")

	// Resource errors
	ErrResourceExhausted = errors.New("resource exhausted")
	ErrQuotaExceeded     = errors.New("quota exceeded")
	ErrRateLimited       = errors.New("rate limited")
	ErrOutOfMemory       = errors.New("out of memory")

	// Permission errors
	ErrUnauthorized = errors.New("unauthorized")
	ErrForbidden    = errors.New("forbidden")
	ErrAccessDenied = errors.New("access denied")
)

Common sentinel errors used throughout the codebase

Functions

func IsClosed

func IsClosed(err error) bool

IsClosed checks if an error indicates a closed resource

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a "not found" error

func IsPermanent

func IsPermanent(err error) bool

IsPermanent checks if an error is permanent and should not be retried

func IsTemporary

func IsTemporary(err error) bool

IsTemporary checks if an error is temporary and can be retried

func IsTimeout

func IsTimeout(err error) bool

IsTimeout checks if an error is a timeout

func Join

func Join(errs ...error) error

Join combines multiple errors into a single error

func Wrap

func Wrap(err error, category Category, message string) error

Wrap creates a new WrappedError with the given category and message

func WrapWithContext

func WrapWithContext(err error, category Category, message string, context map[string]interface{}) error

WrapWithContext creates a new WrappedError with context information

Types

type Category

type Category string

Error categories for grouping related errors

const (
	CategoryDatabase   Category = "database"
	CategoryNetwork    Category = "network"
	CategoryValidation Category = "validation"
	CategoryState      Category = "state"
	CategoryResource   Category = "resource"
	CategoryPermission Category = "permission"
	CategoryInternal   Category = "internal"
	CategoryUnknown    Category = "unknown"
)

func GetCategory

func GetCategory(err error) Category

GetCategory returns the category of an error

type Multi

type Multi struct {
	Errors []error
}

Multi combines multiple errors into a single error

func (*Multi) Add

func (m *Multi) Add(err error)

Add adds an error to the multi-error

func (*Multi) Err

func (m *Multi) Err() error

Err returns nil if there are no errors, otherwise returns the Multi error

func (*Multi) Error

func (m *Multi) Error() string

Error implements the error interface

type WrappedError

type WrappedError struct {
	Err      error
	Category Category
	Message  string
	Context  map[string]interface{}
}

WrappedError provides context around an error

func (*WrappedError) Error

func (e *WrappedError) Error() string

Error implements the error interface

func (*WrappedError) Is

func (e *WrappedError) Is(target error) bool

Is checks if the error matches a target error

func (*WrappedError) Unwrap

func (e *WrappedError) Unwrap() error

Unwrap returns the underlying error

Jump to

Keyboard shortcuts

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