This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
enabled stack trace when the original error support it (in dev and event) #2361
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.
What is being done in this PR?
What are the main choices made to get to this solution?
Previously, we deprecated support of
errors.WithStack()
frompkg/errors
to reduce dependencies, because that is only useful when the user application supports it and is mostly useless or just verbose. Now, the fix just uses the format verb%+v
to support it, and it can support the others if they support the verb too. Flexible, and no additional dependency.The result of the fix
The routing error causes 404 and we don't need a trace for that. It is clear enough.
404 by database missing also clear enough, we don't care 4xx errors.
We cannot get the stack if the user's handler just returned a simple error something like
return fmt.Errorf("internal error")
.When the user's handler returned an error support
%+v
, likereturn errors.New("internal error")
withpkg/errors
, we can see the stack trace.Related PRs:
[1] #138
[2] #1643
[3] #1930
[4] #2352
fixes #1904
obsoletes #2358