1package helpers
2
3import "github.com/labstack/echo/v4"
4
5func InputError(e echo.Context, custom *string) error {
6 msg := "InvalidRequest"
7 if custom != nil {
8 msg = *custom
9 }
10 return genericError(e, 400, msg)
11}
12
13func ServerError(e echo.Context, suffix *string) error {
14 msg := "Internal server error"
15 if suffix != nil {
16 msg += ". " + *suffix
17 }
18 return genericError(e, 400, msg)
19}
20
21func genericError(e echo.Context, code int, msg string) error {
22 return e.JSON(code, map[string]string{
23 "error": msg,
24 })
25}