Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zap.Error should check if the error implements ObjectMarshaller first #641

Closed
nhooyr opened this issue Oct 1, 2018 · 2 comments
Closed

Comments

@nhooyr
Copy link

nhooyr commented Oct 1, 2018

Would be neat to have structured errors.

@akshayjshah
Copy link
Contributor

Our intention with the strongly-typed field constructors was to make the output obvious and predictable. If you'd like this sort of type-sniffing, zap.Any is probably a better fit.

Depending on where you're ingesting your logs, adding this feature as you've described will break indexing in many systems. For example, ElasticSearch becomes very unhappy if one message contains "error": {"foo": "bar"} and another contains "error": {"foo": 42}, since error.foo now has an inconsistent type. The current implementation of zap.Error goes really far out of its way to accommodate a variety of fancy error packages without introducing any type conflicts.

@nhooyr
Copy link
Author

nhooyr commented Nov 22, 2019

Going to close as it has been a long time and I'm not sure if this is relevant anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants