Improved error handling

This commit is contained in:
video-prize-ranch
2022-09-13 16:31:55 -04:00
parent 1263e66f45
commit 5944b7253d
7 changed files with 68 additions and 5 deletions

16
main.go
View File

@@ -30,6 +30,22 @@ func main() {
Prefork: utils.Config["fiberPrefork"].(bool),
UnescapePath: true,
StreamRequestBody: true,
ErrorHandler: func(ctx *fiber.Ctx, err error) error {
code := fiber.StatusInternalServerError
if e, ok := err.(*fiber.Error); ok {
code = e.Code
}
err = ctx.Status(code).Render("errors/error", fiber.Map{
"err": err,
})
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
return nil
},
})
app.Use(recover.New(recover.Config{