mirror of
https://github.com/macports/mpbot-github.git
synced 2026-07-13 03:18:39 -07:00
Log stack trace when recovering from a panic
Apparently that's possible by attempting to capture a stack trace at this location, even though it isn't the location where the error was thrown, at least according to [1]. It seems to work in my testing. [1]: https://groups.google.com/g/golang-nuts/c/MB8GyW5j2UY/m/xt54dFicvxoJ
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -15,7 +16,7 @@ var cveRegexp = regexp.MustCompile(`CVE-\d{4}-\d+`)
|
||||
func (receiver *Receiver) handlePullRequest(body []byte) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Println(r)
|
||||
log.Printf("PR processing failed: %s\n%s", r, debug.Stack())
|
||||
}
|
||||
|
||||
if !receiver.testing {
|
||||
|
||||
Reference in New Issue
Block a user