-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add ErrorHandlerFunc #183
Add ErrorHandlerFunc #183
Conversation
Towards #173 |
Code looks good, can we add a test that uses the ErrorHandlerFunc. |
Updated
My thoughts are thus:
Ideally we'd share as much of this sort of code between all as-es (raw, http, thrift, json, etc). |
880baca
to
571f150
Compare
I'm happy with getting rid of However, E.g. this test actually means that a handler returning The tests should have caught this extra log message, but log verification was broken recently by some interface changes. I'm fixing that in #186 which we should rebase this change off, which should cause the test to fail due to an unexpected log message. |
// Handle calls f(ctx, call) | ||
func (f ErrorHandlerFunc) Handle(ctx context.Context, call *InboundCall) { | ||
if err := f(ctx, call); err != nil { | ||
call.log.WithFields(ErrField(err)).Error("Handler error.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below, we should add the handlerr name (which should be accessible via call
) so the error log has more information
571f150
to
9615a6d
Compare
Added error log annotate. Good note about undue logging, I'll add some filtering after that eventual rebase so that we only log certain system errors; at the very least we want unexpected errors (and especially errors that are only coded as unexpected "by default" by not actually being SystemError s). |
Merged other PR, so you should be able to rebase. I think only logging unexpected errors make sense. |
9615a6d
to
397368e
Compare
Rebased and changed to only log unexpected errors (and to ignore any error returned by |
code lgtm. Would be good to also have a similar test with an unexpected error being returned just to have coverage on that branch. too |
397368e
to
92f4099
Compare
Added test case for unexpected handler error |
test looks good, lgtm 🚢 |
A simple corollary of HandlerFunc which allows the wrapped function to return
an error and handles returning a minimal error response.
r @prashantv @akshayjshah