mirror of
https://github.com/mjl-/mox.git
synced 2025-06-30 12:48:14 +03:00
for webapi requests, make canceled contexts a user instead of server error
no need to trigger alerts for user-initiated errors
This commit is contained in:
parent
1be0cf485e
commit
dfddf0e874
@ -78,7 +78,11 @@ func xcheckf(ctx context.Context, err error, format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
errmsg := fmt.Sprintf("%s: %s", msg, err)
|
||||
pkglog.WithContext(ctx).Errorx(msg, err)
|
||||
panic(&sherpa.Error{Code: "server:error", Message: errmsg})
|
||||
code := "server:error"
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
code = "user:error"
|
||||
}
|
||||
panic(&sherpa.Error{Code: code, Message: errmsg})
|
||||
}
|
||||
|
||||
func xcheckuserf(ctx context.Context, err error, format string, args ...any) {
|
||||
|
@ -230,7 +230,11 @@ func xcheckf(ctx context.Context, err error, format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
errmsg := fmt.Sprintf("%s: %s", msg, err)
|
||||
pkglog.WithContext(ctx).Errorx(msg, err)
|
||||
panic(&sherpa.Error{Code: "server:error", Message: errmsg})
|
||||
code := "server:error"
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
code = "user:error"
|
||||
}
|
||||
panic(&sherpa.Error{Code: code, Message: errmsg})
|
||||
}
|
||||
|
||||
func xcheckuserf(ctx context.Context, err error, format string, args ...any) {
|
||||
|
@ -117,7 +117,11 @@ func xcheckf(ctx context.Context, err error, format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
errmsg := fmt.Sprintf("%s: %s", msg, err)
|
||||
pkglog.WithContext(ctx).Errorx(msg, err)
|
||||
panic(&sherpa.Error{Code: "server:error", Message: errmsg})
|
||||
code := "server:error"
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
code = "user:error"
|
||||
}
|
||||
panic(&sherpa.Error{Code: code, Message: errmsg})
|
||||
}
|
||||
|
||||
func xcheckuserf(ctx context.Context, err error, format string, args ...any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user