trace

package
v1.0.75 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULE   string = "module"
	SERVICE  string = "service"
	ACTIVITY string = "activity"
	PACKAGE  string = "package"
	URL      string = "url"
	PATH     string = "path"
	AGENT    string = "agent"
	ID       string = "id"
	SOURCE   string = "source"
	ORIGIN   string = "origin"
	SIZE     string = "size"
	NAME     string = "name"
)

Variables

View Source
var ErrorTraceFieldName = "_trace"

Functions

func ConsoleTraceWriter

func ConsoleTraceWriter() zerolog.ConsoleWriter

ConsoleTraceWriter creates a zerolog console writer configured for trace output

func ErrorMarshalFunc

func ErrorMarshalFunc(err error) interface{}

ErrorMarshalFunc marshals an error chain into a map with trace information and fields

Types

type CodedErr

type CodedErr[T any] struct {
	Err
	// contains filtered or unexported fields
}

CodedErr is a generic error type that embeds Err and includes a typed code field

func CodedError

func CodedError[T any]() *CodedErr[T]

CodedError creates a new CodedErr instance with the given code

func (*CodedErr[T]) Code

func (e *CodedErr[T]) Code(code T) *CodedErr[T]

Code sets the error code

func (*CodedErr[T]) Field

func (e *CodedErr[T]) Field(key string, value any) *CodedErr[T]

Field adds a single key-value pair to the error's fields (overrides Err.Field to return *CodedErr[T])

func (*CodedErr[T]) Fields

func (e *CodedErr[T]) Fields(f map[string]any) *CodedErr[T]

Fields copies all key-value pairs from the provided map to the error's fields (overrides Err.Fields to return *CodedErr[T])

func (*CodedErr[T]) GetCode

func (e *CodedErr[T]) GetCode() T

GetCode returns the error code

func (*CodedErr[T]) Msg

func (e *CodedErr[T]) Msg(msg string) *CodedErr[T]

Msg sets the error message (overrides Err.Msg to return *CodedErr[T])

func (*CodedErr[T]) Msgf

func (e *CodedErr[T]) Msgf(msg string, args ...any) *CodedErr[T]

Msgf sets the error message (overrides Err.Msgf to return *CodedErr[T])

func (*CodedErr[T]) Wrap

func (e *CodedErr[T]) Wrap(cause error) *CodedErr[T]

Wrap sets the underlying cause error (overrides Err.Wrap to return *CodedErr[T])

type Err

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

Err containing a chain of causes (linked list of errors)

func Error

func Error() *Err

Error creates a new Err instance

func (*Err) Error

func (e *Err) Error() string

Err returns the error message, implementing the error interface

func (*Err) Field

func (e *Err) Field(key string, value any) *Err

Field adds a single key-value pair to the error's fields

func (*Err) Fields

func (e *Err) Fields(f map[string]any) *Err

Fields copies all key-value pairs from the provided map to the error's fields

func (*Err) GetField

func (e *Err) GetField(field string) any

GetField returns the value of the field with the given key

func (*Err) HasField

func (e *Err) HasField(field string) bool

HasField checks if the error has a field with the given key

func (*Err) Msg

func (e *Err) Msg(msg string) *Err

Msg sets the error message

func (*Err) Msgf

func (e *Err) Msgf(msg string, args ...any) *Err

Msgf sets the error message

func (*Err) Unwrap

func (e *Err) Unwrap() error

Unwrap returns the underlying cause error

func (*Err) Wrap

func (e *Err) Wrap(cause error) *Err

Wrap sets the underlying cause error

Jump to

Keyboard shortcuts

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