Discover Packages
github.com/KernelPryanic/goudpscan
pkg
ctxerr
package
Version:
v0.4.0
Opens a new window with list of versions in this module.
Published: Feb 10, 2025
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package ctxerr provides functions to extract context information from errors.
Ctx adds the context error to ctx.
Use this to pass the context error to the logger.
Logger will automatically extract the error with its context values and log them.
Example:
logger.Error().Ctx(ctxerr.Ctx(context.Background(), err)).Msg("an error occurred")
With adds the error context values by wrapping err into ctxerr.Error.
Use this to propagate contextual information up the call stack.
Example:
return ctxerr.With(err, map[string]any{"user_id": 1})
CtxErr is an error type that contains contextual information fields
related to the error. It's used to propagate fields up the call stack.
From reads the error from ctx, if any.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.