Releases: mvndaai/ctxerr
Releases · mvndaai/ctxerr
add CallerFuncs
Support `errors.Join` & getting fields from other err types
- The functions
AllFields
,HasField
, andHasCategory
now dow a depth first search over the error tree and handleerrors.Join
that was added in Go1.20. - Chagned
AllFields
,HasField
, andHasCategory
to get fields from an interface of justFields() map[string]any
instead of theCtxErr interface
what needed a context. Now any error that has that interface can give fields not just ones from this package. - Added configurable functions to allow adding more field getting functions so if someone prefers the interface
FieldMap() map[string]any
then they could configure ctxerr to allow that too.
[Backwards incompatible] Fix field hooks
- Change the file signature for field hooks to include context
- Remove
echo
andopencensus
sub packages. They will be added to ctxerrhelper
add FieldHooks
This allows adding func(any) any functions that get run on SetField(s) which can do things like auto redact structs.
FIx Godoc & add QuickWrap to instance
- The comments for the HTTP functions were copied and pasted wrong and needed fixing.
- QuickWrap was missed when creating instance so that was added.
Fix HTTP func to use instance
I missed this with the recent change to there being instances of ctxerr instead of just global in case you want different hooks. The HTTP functions always used the global which was a problem.
fix panic on Fields with nil context
v0.10.3 fix panic on Fields with nil context (#5)
Readme updates; http traceID key
v0.10.2 depricate http TraceID func (#4)
Instance cleanup
Change functions from (in *Instance)
to (in Instance)
when possible to avoid nil pointer exceptions.
When (in *Instance)
is required and is nil added pretty panic to help debugging.
HasField and Instance
New function HasField
recursively unwraps to see if a field exists.
Instance
There is a new Instance
struct to enable configuration of a non-global New
s, Wrap
s, and Handle
.
CreateHooks
are functions to update the context one aNew
/Wrap
HandleHooks
are functions that happen onHandle
FieldsAsSlice
makes gettingAllFields
return a slice of all values rather than the deepest
This allows for better testing. There are no longer private global configurations.