errors

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogErrorChain

func LogErrorChain(err error)

LogErrorChain logs an error chain to the console.

func LogErrorChainWithAttrs

func LogErrorChainWithAttrs(err error)

LogErrorChainWithAttrs logs an error chain with additional attributes in a structured format.

func Wrap

func Wrap(msg string, args ...any) error

Wrap creates a TempoError with a given message, optional cause, and formatting arguments. If the first variadic argument is an error, it is treated as the cause.

Types

type TempoError

type TempoError struct {
	Code    int            // Error code
	Message string         // Context message for the error
	Cause   error          // Underlying cause of the error, if any
	Attrs   map[string]any // Additional attributes for the error
}

TempoError represents an error with an additional context message, cause, and attributes.

func NewTempoError

func NewTempoError(message string, cause error) *TempoError

NewTempoError creates a new TempoError instance.

func (*TempoError) Error

func (e *TempoError) Error() string

Error returns the context message of the TempoError.

func (*TempoError) ToJSON

func (e *TempoError) ToJSON() ([]byte, error)

func (*TempoError) Unwrap

func (e *TempoError) Unwrap() error

Unwrap returns the underlying cause of the error, if any.

func (*TempoError) WithAttr

func (e *TempoError) WithAttr(key string, value any) *TempoError

WithAttr adds a key-value pair to the attributes and returns the updated error.

func (*TempoError) WithCode

func (e *TempoError) WithCode(code int) *TempoError

WithCode adds an error code to the TempoError and returns the updated error.

type TempoErrorInterface

type TempoErrorInterface interface {
	error
	Code() int
	Attrs() map[string]any
}

TempoErrorInterface defines the interface for TempoError with extended capabilities.

Jump to

Keyboard shortcuts

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