mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 19:21:37 +00:00
Fix error recovery.
This commit is contained in:
@@ -18,7 +18,9 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -26,7 +28,15 @@ import (
|
||||
func HandleCrash() {
|
||||
r := recover()
|
||||
if r != nil {
|
||||
log.Printf("Recovered from panic: %#v", r)
|
||||
callers := ""
|
||||
for i := 0; true; i++ {
|
||||
_, file, line, ok := runtime.Caller(i)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
callers = callers + fmt.Sprintf("%v:%v\n", file, line)
|
||||
}
|
||||
log.Printf("Recovered from panic: %#v (%v)\n%v", r, r, callers)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user