-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't panic when a Stringer field value is nil
This commit ensures that zap.Stringer won't cause a panic when the given field value is nil or a typed nil[1]. In fact any panic caused by the Stringer implementation would be recovered and printed. For panic("foo") for a field k we would see kError=foo within the log. A panic with an error would result in the error message in kError. Other kinds of panic values are simply printed as "<unknown>" since trying to convert the value itself could cause a panic again which would trigger the panic within recover panic. [1]: https://golang.org/doc/faq#nil_error
- Loading branch information
Showing
2 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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