feat: v0.2.0 — add ErrAny for recover() payloads#2
Merged
Conversation
1.recover() returns any not error -> ErrAny accepts any 2.error input could share Err logic -> delegate when err 3.nil input would emit empty fields -> return nil safely
1.Reader saw Err() as redundant under ecszap -> add subsection 2.Coverage table missed ErrAny -> bump to ~117 helpers 3.CHANGELOG had only Unreleased -> log v0.2.0 entry
There was a problem hiding this comment.
Pull request overview
Adds a new zap subpackage helper to extract ECS error.* fields from recover() payloads (typed as any), and updates documentation to clarify how ecsfields error helpers relate to zap.Error(err) when using the ecszap encoder.
Changes:
- Introduce
ErrAny(v any)to emit ECS error fields for non-errorpanic payloads while delegating toErr(err)when possible. - Add unit tests covering
ErrAnyfor nil, error, stack-tracer error, and several non-error payload types. - Update README, ECS coverage docs, and CHANGELOG for v0.2.0 and the new helper.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| zap/error.go | Adds ErrAny(any) helper for recover() payloads and documents intended usage. |
| zap/error_test.go | Adds tests validating ErrAny behavior across error and non-error inputs. |
| README.md | Updates coverage counts and documents how to choose between ecsf.Err* helpers and zap.Error. |
| docs/ecs-coverage.md | Updates coverage matrix to include ErrAny() and bumps version label/count. |
| CHANGELOG.md | Adds v0.2.0 entry describing ErrAny and the documentation clarification. |
1.recover(typedNilErr) would panic in err.Error() -> typed-nil check 2.Lost type info on nil error harmed debugging -> emit error.type 3.Defense covers all nillable kinds not just Ptr -> reflect.Kind switch
1.pkg/errors users got message+type but no stack -> add interface 2.Two interfaces share extraction logic -> extractStackTrace helper 3.GoDoc warned pkg/errors unsupported -> update to both supported
1.zap.Error stack was overstated -> qualify with StackTracer 2.Err now also reads pkg/errors -> note dual interface support 3.CHANGELOG missed pkg/errors and typed-nil -> add entries
1.Coverage said StackTrace bytes only -> note both interfaces 2.pkg/errors users had no signal in coverage -> name it
1.errors.StackTrace clashed visually with stdlib -> pkgerrors prefix 2.errors.New/Wrap reads as stdlib in package doc -> pkgerrors prefix 3.Markdown lacks import context too -> use same prefix everywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ErrAny(v any) []zap.Fieldfor non-errorpanic recovery values (recover()returnsany).ecsf.Err, single-field error helpers, andzap.Error(err)when paired with the ecszap encoder.Why
Surfaced from streaming-observer dogfooding of v0.1.0:
fmt.Sprint(recovered)+fmt.Sprintf("%T", recovered)becauseErr(error)doesn't acceptany.ErrAnyremoves that boilerplate and delegates toErrwhen the value is actually anerror.zap.Error(err)under ecszap already produces ECS-shaped output, almost causing unnecessary scope creep when migrating call sites.API
Typical panic recovery:
Test plan
make checkpasses (fmt + lint + race-detector test)