diff --git a/webaccount/account.go b/webaccount/account.go index 6782747..11132c5 100644 --- a/webaccount/account.go +++ b/webaccount/account.go @@ -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) { diff --git a/webadmin/admin.go b/webadmin/admin.go index 5cd21ae..103e5fe 100644 --- a/webadmin/admin.go +++ b/webadmin/admin.go @@ -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) { diff --git a/webmail/webmail.go b/webmail/webmail.go index b331444..dbcb3be 100644 --- a/webmail/webmail.go +++ b/webmail/webmail.go @@ -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) {