1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

add stacktrace on panic.

This commit is contained in:
Mrs4s 2020-12-07 10:51:30 +08:00
parent 35a1a0f8b5
commit d8b9eb611f

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -316,7 +317,7 @@ func (s *websocketServer) listenApi(c *websocketConn) {
func (c *websocketConn) handleRequest(bot *coolq.CQBot, payload []byte) { func (c *websocketConn) handleRequest(bot *coolq.CQBot, payload []byte) {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
log.Printf("处置WS命令时发生无法恢复的异常%v", err) log.Printf("处置WS命令时发生无法恢复的异常%v\n%s", err, debug.Stack())
c.Close() c.Close()
} }
}() }()