1package helpers
2
3import "github.com/labstack/echo/v4"
4
5func InputError(e echo.Context, error, msg string) error {
6 if error == "" {
7 return e.NoContent(400)
8 }
9
10 resp := map[string]string{}
11 resp["error"] = error
12 if msg != "" {
13 resp["message"] = msg
14 }
15
16 return e.JSON(400, resp)
17}
18
19func ServerError(e echo.Context, error, msg string) error {
20 if error == "" {
21 return e.NoContent(500)
22 }
23
24 resp := map[string]string{}
25 resp["error"] = error
26 if msg != "" {
27 resp["message"] = msg
28 }
29
30 return e.JSON(500, resp)
31}