Skip to content

Commit 48e52ed

Browse files
committed
## 0.2.0-beta11 gf web support gerror CodeNil
1 parent b654ad3 commit 48e52ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/goframe/web/gf.go

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/glennliao/apijson-go/consts"
1313
"github.com/glennliao/apijson-go/model"
1414
"github.com/gogf/gf/v2/container/gmap"
15+
"github.com/gogf/gf/v2/errors/gcode"
1516
"github.com/gogf/gf/v2/errors/gerror"
1617
"github.com/gogf/gf/v2/frame/g"
1718
"github.com/gogf/gf/v2/net/ghttp"
@@ -159,6 +160,16 @@ func CommonResponse(handler func(ctx context.Context, req model.Map) (res model.
159160
code = 500
160161
msg = "系统异常"
161162
}
163+
}
164+
165+
if e, ok := err.(*gerror.Error); ok {
166+
if e.Code() == gcode.CodeNil {
167+
code = 400
168+
msg = e.Error()
169+
} else {
170+
code = 500
171+
msg = "系统异常"
172+
}
162173
} else {
163174
code = 500
164175
msg = "系统异常"

0 commit comments

Comments
 (0)