添加在err方法输出data的函数
This commit is contained in:
+6
-2
@@ -9,8 +9,8 @@ import (
|
||||
"math"
|
||||
"net/http"
|
||||
|
||||
"github.com/yuninks/langx"
|
||||
"github.com/yuninks/errorx"
|
||||
"github.com/yuninks/langx"
|
||||
"github.com/zeromicro/go-zero/core/trace"
|
||||
)
|
||||
|
||||
@@ -66,6 +66,10 @@ func SuccessWithPage(ctx context.Context, w http.ResponseWriter, data interface{
|
||||
|
||||
// 失败的响应
|
||||
func Error(ctx context.Context, w http.ResponseWriter, err error) {
|
||||
ErrorWithData(ctx, w, err, "")
|
||||
}
|
||||
|
||||
func ErrorWithData(ctx context.Context, w http.ResponseWriter, err error, data interface{}) {
|
||||
code := op.defaultErrorCode
|
||||
msg := "请求失败"
|
||||
if err != nil {
|
||||
@@ -77,7 +81,7 @@ func Error(ctx context.Context, w http.ResponseWriter, err error) {
|
||||
}
|
||||
msg = err.Error()
|
||||
}
|
||||
ResponseCtx(ctx, w, code, msg, "")
|
||||
ResponseCtx(ctx, w, code, msg, data)
|
||||
}
|
||||
|
||||
func ErrorStr(ctx context.Context, w http.ResponseWriter, msg string) {
|
||||
|
||||
Reference in New Issue
Block a user