-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement api to accept empty error #94
Comments
This is interesting but it seems very similar to using throw/catch versus Go's indented error paths idiom. |
I can see what you mean, but it does not affect how to logically handle the error, just how to log it. |
Let me just say first that I fully agree Go takes the whole indent every error path thing way too far and it gets very repetitive. But slog aims to follow Go idioms. And handling an error is no different than logging it. I wouldn't stop such a change though if the Go team @cdr was in majority support. |
Or sorry not no different, I meant logging is part of handling an error. |
Zerolog has this nifty api
log.Err(err error)
that isError
level iferr != nil
andInfo
level iferr == nil
The basic gist to avoid this common code:
and you can just do (the message becomes the action, and the Error level indicates the action failed):
It is a small feature I miss. Let me know what you think.
The text was updated successfully, but these errors were encountered: