raven-go
raven-go copied to clipboard
Log error message in RecoveryHandler
The default behavior of the default Go http panic handler is to display the error message and the stack trace. When I use raven.RecoveryHandler it outputs only the stack trace, which makes debugging difficult.
Default behavior:
func handler(w http.ResponseWriter, r *http.Request) {
var x []int
x[1] = 1
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
2016/07/11 13:49:24 http: panic serving [::1]:50020: runtime error: index out of range
goroutine 25 [running]:
[stack trace]
With RecoveryHandler:
func main() {
http.HandleFunc("/", raven.RecoveryHandler(handler))
http.ListenAndServe(":8080", nil)
}
goroutine 21 [running]:
[stack trace]
This pull request makes RecoveryHandler output look like:
2016/07/11 14:19:41 runtime error: index out of range
goroutine 6 [running]:
[stack trace]