mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-13 19:55:21 +00:00
Improved error handling
This commit is contained in:
16
main.go
16
main.go
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user