libError

package
v0.12.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append added in v0.5.7

func Append(err error, errChild error, format string, args ...any) error

func Join

func Join(err error, format string, args ...any) error

func ToSnakeCase added in v0.12.0

func ToSnakeCase(str string) string

Types

type Action added in v0.12.0

type Action struct {
	Status      status.StatusCode `json:"status"`
	Description string            `json:"description"`
	Message     any               `json:"message"`
}

func (Action) Format added in v0.12.0

func (a Action) Format(stack *strings.Builder)

func (Action) SLog added in v0.12.0

func (a Action) SLog() slog.Attr

type Error added in v0.12.0

type Error interface {
	error
	Action() Action
	Src() *Source
	Format(*strings.Builder)
	SLog() slog.Attr
}

func Add added in v0.12.0

func Add(err Error, status status.StatusCode, desc string, message any) Error

wraps child error with parent status code and desc

func Convert added in v0.12.0

func Convert(err error, status status.StatusCode, desc string, message any) Error

func New added in v0.12.0

func New(status status.StatusCode, desc string, format string, a ...any) Error

creates new error object

type ErrorData added in v0.12.0

type ErrorData struct {
	Time       time.Time
	ActionData Action  `json:"action"`
	Source     *Source `json:"source,omitempty"`
	Child      Error   `json:"children"`
}

func (ErrorData) Action added in v0.12.0

func (e ErrorData) Action() Action

func (ErrorData) Error added in v0.12.0

func (e ErrorData) Error() string

func (ErrorData) Format added in v0.12.0

func (e ErrorData) Format(stack *strings.Builder)

func (ErrorData) SLog added in v0.12.0

func (e ErrorData) SLog() slog.Attr

func (ErrorData) Src added in v0.12.0

func (e ErrorData) Src() *Source

type Source added in v0.12.0

type Source struct {
	File string `json:"file"`
	Line int    `json:"line"`
}

func GetStack added in v0.12.0

func GetStack() *Source

func (Source) Format added in v0.12.0

func (s Source) Format(stack *strings.Builder)

func (Source) SLog added in v0.12.0

func (s Source) SLog() slog.Attr

Jump to

Keyboard shortcuts

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