Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

ctxerr

This package provides functionality of propagation failure context information through errors. It's designed to enhance error logging with additional contextual information and pass it up the call stack. It's designed to be used with the log package in mind.

Usage

funcfuncA(ctx context.Context) {
...logger:=log.Defaultiferr:=funcB(ctx); err!=nil {
logger.Error().Ctx(ctxerr.Ctx(ctx, err)).Msg("An error occurred")
}
...
}
funcfuncB() error {
...iferr:=funcC(ctx); err!=nil {
returnctxerr.With(err, map[string]any{"operation": "someOperation", "details": "additional info"})
}
returnnil
}

About

A tiny, handy package for contextual error types. Use it when you need to pass additional context to errors.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages