Skip to content

Commit d2d8b62

Browse files
Update pkg/codegen/templates/strict/strict-gin.tmpl
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent 65dedd1 commit d2d8b62

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/codegen/templates/strict/strict-gin.tmpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareF
3131
}
3232

3333
func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictGinServerOptions) ServerInterface {
34+
if options.RequestErrorHandlerFunc == nil {
35+
options.RequestErrorHandlerFunc = func(ctx *gin.Context, err error) {
36+
ctx.JSON(http.StatusBadRequest, gin.H{"msg": err.Error()})
37+
}
38+
}
39+
if options.HandlerErrorFunc == nil {
40+
options.HandlerErrorFunc = func(ctx *gin.Context, err error) {
41+
ctx.JSON(http.StatusInternalServerError, gin.H{"msg": err.Error()})
42+
}
43+
}
44+
if options.ResponseErrorHandlerFunc == nil {
45+
options.ResponseErrorHandlerFunc = func(ctx *gin.Context, err error) {
46+
ctx.JSON(http.StatusInternalServerError, gin.H{"msg": err.Error()})
47+
}
48+
}
3449
return &strictHandler{ssi: ssi, middlewares: middlewares, options: options}
3550
}
3651

0 commit comments

Comments
 (0)