Skip to content

Commit

Permalink
refactor(ginrpc): update error handling to use srv.Error
Browse files Browse the repository at this point in the history
- Replace gins.ResultError with srv.Error for consistent error handling
- Update error handling for BindBody, BindQuery, and BindURI
  • Loading branch information
godcong committed Dec 6, 2024
1 parent c29b892 commit 1d621ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/protoc-gen-go-ginrpc/ginrpc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ func Register{{.ServiceType}}GINRPCAgent (router gins.IRouter, srv {{.ServiceTyp
var in {{.Request}}
{{- if.HasBody}}
if err := gins.BindBody(ctx,&in{{.Body}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- end}}
if err := gins.BindQuery(ctx,&in{{.Query}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- if.HasVars}}
if err := gins.BindURI(ctx,&in{{.Vars}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- end}}
Expand Down

0 comments on commit 1d621ce

Please sign in to comment.