24 lines
451 B
Go
24 lines
451 B
Go
|
package handler
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
)
|
||
|
|
||
|
func RenderError(c *fiber.Ctx, err error, message string) error {
|
||
|
if err != nil {
|
||
|
log.Printf("renderError: %s\n", err)
|
||
|
}
|
||
|
return c.Render("error", fiber.Map{
|
||
|
"message": message,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func JSONError(c *fiber.Ctx, status int, err error, message string) error {
|
||
|
if err != nil {
|
||
|
log.Printf("JSONError: %s\n", err)
|
||
|
}
|
||
|
return c.Status(status).SendString("error: " + message)
|
||
|
}
|