From 1e683fcf95dc74fece4af5c8f48c1c05e14ba658 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 23 Mar 2023 09:48:11 +0800 Subject: [PATCH] api error --- pkg/apiresp/resp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/apiresp/resp.go b/pkg/apiresp/resp.go index 688fc5b6a..06001a541 100644 --- a/pkg/apiresp/resp.go +++ b/pkg/apiresp/resp.go @@ -42,7 +42,11 @@ func apiSuccess(data any) *apiResponse { func apiError(err error) *apiResponse { unwrap := errs.Unwrap(err) if codeErr, ok := unwrap.(errs.CodeError); ok { - return &apiResponse{ErrCode: codeErr.Code(), ErrMsg: codeErr.Msg(), ErrDlt: codeErr.Detail()} + resp := apiResponse{ErrCode: codeErr.Code(), ErrMsg: codeErr.Msg(), ErrDlt: codeErr.Detail()} + if resp.ErrDlt == "" { + resp.ErrDlt = err.Error() + } + return &resp } return &apiResponse{ErrCode: errs.ServerInternalError, ErrMsg: err.Error()} }