Skip to content

Commit 4db7760

Browse files
committed
Update xutil ErrorAlert
1 parent 4417673 commit 4db7760

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/xutil/alert.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,21 @@ func SendAlert(ctx context.Context, title, content string, mentionAll bool) erro
110110
}
111111

112112
// ErrorAlert 错误警报
113-
func ErrorAlert(err error) {
113+
func ErrorAlert(err error, needStack bool) {
114114
if err == nil {
115115
return
116116
}
117117

118118
_, file, line, _ := runtime.Caller(1)
119-
uuid := fmt.Sprintf("%s:%d", file, line)
119+
fileLine := fmt.Sprintf("%s:%d", file, line)
120120

121121
title := fmt.Sprintf("ERROR: %s", err)
122-
content := fmt.Sprintf("%s:%d\n%s", file, line, string(debug.Stack()))
122+
content := fileLine
123+
if needStack {
124+
content = fmt.Sprintf("%s\n%s", content, string(debug.Stack()))
125+
}
126+
127+
uuid := fileLine
123128

124129
_ = PushAlert(context.Background(), title, content, uuid, true)
125130
}

0 commit comments

Comments
 (0)