This commit is contained in:
oneao committed 2025-11-23 22:43:57 +08:00
1 parent ac0843c041
commit a917be08d1
65 files changed
+8043

No files matched your search

@@ -0,0 +1,19 @@
package middleware
import (
"context"
"github.com/cloudwego/hertz/pkg/app"
)
// Error 中间件
func Error() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
c.Next(ctx)
if err := c.Errors.Last(); err != nil {
// 未知错误 -> 500
c.JSON(500, ErrorResponse{500, "Internal Server Error"})
}
}
}