-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
error-reporting: fix up sample #53
Comments
At @broady you mean this golang-samples/docs/error-reporting/fluent/main.go Lines 55 to 69 in be19f2b
IMHO it suffices and doesn't need removing to use panic, because it shows the user how to capture the stacktrace for their bug report. What do you think? |
Yep, that one. I guess it's fine, but I don't fully understand the usage of error reporting for Go. Do we really want people to only use it for panics? /cc @rakyll |
There's a package that may simplify the code a little; github.com/pkg/errors import (
"github.com/pkg/errors"
)
...
// Handler for the incoming requests.
func demoHandler(w http.ResponseWriter, r *http.Request) {
err := errors.Error("Runtime Issue with demoHandler")
if err != nil {
report(err, r)
}
}
func report(err Error, r *http.Request) {
...
"stacktrace": errors.Errorf("%+v", err)
...
} I'm not sure, though, how helpful stack traces are as Rob Pike has written that errors should be given context before before bubbled up the stack or dealt with without causing the system to fall over. Using the errors pkg we could now wrap one error context within another potentially creating a much nicer and helpful error message rather than a stack trace (remembers screens full of java stack traces....!) Just my two pennies. |
@broady @odeke-em I haven't seen any feedback about this. Do you still have ideas about how to improve it, or should we close this? @Brotherhod Thanks for the link and example. I'd prefer to avoid using any additional external dependencies. |
Declaring issue bankruptcy on this. Feel free to reopen if you want to fix it. |
The whole divide by zero thing is weird. Just use
panic
or remove the panic/defer code completely.The text was updated successfully, but these errors were encountered: