Skip to content

Commit

Permalink
feat: check error type first
Browse files Browse the repository at this point in the history
  • Loading branch information
dapeng committed Jul 13, 2024
1 parent 9b4b056 commit 2cf8862
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions goner/gin/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type HandleProxyToGin interface {
type XContext interface {
JSON(code int, obj any)
String(code int, format string, values ...any)
Abort()
}

type WrappedDataFunc func(code int, msg string, data any) any
Expand Down
8 changes: 8 additions & 0 deletions goner/gin/responer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ func (r *responser) Failed(ctx XContext, oErr error) {
}

func (r *responser) ProcessResults(context XContext, writer gin.ResponseWriter, last bool, funcName string, results ...any) {
for _, result := range results {
if err, ok := result.(error); ok {
r.Failed(context, err)
context.Abort()
return
}
}

isNotEnd := false
for _, result := range results {
if result == nil {
Expand Down

0 comments on commit 2cf8862

Please sign in to comment.