endpoint returning tree of categories

This commit is contained in:
Daniel Goc
2026-03-20 12:38:41 +01:00
parent 0d29d8f6a2
commit b67c4e3aef
6 changed files with 144 additions and 30 deletions

View File

@@ -48,6 +48,9 @@ var (
// Typed errors for product list handler
ErrBadPaging = errors.New("bad or missing paging attribute value in header")
// Typed errors for menu handler
ErrNoRootFound = errors.New("no root found in categories table")
)
// Error represents an error with HTTP status code
@@ -135,6 +138,9 @@ func GetErrorCode(c fiber.Ctx, err error) string {
case errors.Is(err, ErrBadPaging):
return i18n.T_(c, "error.err_bad_paging")
case errors.Is(err, ErrNoRootFound):
return i18n.T_(c, "error.no_root_found")
default:
return i18n.T_(c, "error.err_internal_server_error")
}
@@ -169,7 +175,8 @@ func GetErrorStatus(err error) int {
errors.Is(err, ErrBadAttribute),
errors.Is(err, ErrBadField),
errors.Is(err, ErrInvalidXHTML),
errors.Is(err, ErrBadPaging):
errors.Is(err, ErrBadPaging),
errors.Is(err, ErrNoRootFound):
return fiber.StatusBadRequest
case errors.Is(err, ErrEmailExists):
return fiber.StatusConflict