You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
425 B
24 lines
425 B
package common
|
|
|
|
import (
|
|
"log"
|
|
"fmt"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func Fail(err error, format string, v ...any) error {
|
|
err_format := fmt.Sprintf("ERROR: %v; %s", err, format)
|
|
log.Printf(err_format, v...)
|
|
return err
|
|
}
|
|
|
|
func ApiError(c *fiber.Ctx, format string, args ...any) error {
|
|
c.Status(500)
|
|
|
|
log.Printf(format, args...)
|
|
|
|
return c.JSON(fiber.Map{
|
|
"error": fmt.Sprintf(format, args...),
|
|
})
|
|
}
|
|
|
|
|