Skip to content

Commit

Permalink
## 0.2.0-beta11 gf web support gerror CodeNil
Browse files Browse the repository at this point in the history
  • Loading branch information
glennliao committed Jul 8, 2023
1 parent b654ad3 commit 48e52ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/goframe/web/gf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/glennliao/apijson-go/consts"
"github.com/glennliao/apijson-go/model"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
Expand Down Expand Up @@ -159,6 +160,16 @@ func CommonResponse(handler func(ctx context.Context, req model.Map) (res model.
code = 500
msg = "系统异常"
}
}

if e, ok := err.(*gerror.Error); ok {
if e.Code() == gcode.CodeNil {
code = 400
msg = e.Error()
} else {
code = 500
msg = "系统异常"
}
} else {
code = 500
msg = "系统异常"
Expand Down

0 comments on commit 48e52ed

Please sign in to comment.