code error

This commit is contained in:
withchao
2023-03-16 16:32:42 +08:00
parent 38d3c5d94d
commit 1f935531f6
7 changed files with 272 additions and 15 deletions
+2 -6
View File
@@ -19,12 +19,8 @@ func apiSuccess(data any) *apiResponse {
func apiError(err error) *apiResponse {
unwrap := errs.Unwrap(err)
var dlt string
if unwrap != err {
dlt = err.Error()
}
if codeErr, ok := unwrap.(errs.CodeError); ok {
return &apiResponse{ErrCode: codeErr.Code(), ErrMsg: codeErr.Msg(), ErrDlt: dlt}
return &apiResponse{ErrCode: codeErr.Code(), ErrMsg: codeErr.Msg(), ErrDlt: codeErr.Detail()}
}
return &apiResponse{ErrCode: errs.ServerInternalError, ErrMsg: err.Error(), ErrDlt: dlt}
return &apiResponse{ErrCode: errs.ServerInternalError, ErrMsg: err.Error()}
}