This commit is contained in:
Daniel Goc
2026-04-10 09:13:13 +02:00
parent f1f5daa82b
commit 0a5ce5d9c2
9 changed files with 129 additions and 12 deletions

View File

@@ -49,8 +49,11 @@ var (
ErrAIResponseFail = errors.New("AI responded with failure")
ErrAIBadOutput = errors.New("AI response does not obey the format")
// Typed errors for product list handler
ErrBadPaging = errors.New("bad or missing paging attribute value in header")
// Typed errors for product handler
ErrBadPaging = errors.New("bad or missing paging attribute value in header")
ErrProductNotFound = errors.New("product with provided id does not exist")
ErrAlreadyInFavorites = errors.New("the product already is in your favorites")
ErrNotInFavorites = errors.New("the product already is not in your favorites")
// Typed errors for menu handler
ErrNoRootFound = errors.New("no root found in categories table")
@@ -170,6 +173,12 @@ 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, ErrProductNotFound):
return i18n.T_(c, "error.err_product_not_found")
case errors.Is(err, ErrAlreadyInFavorites):
return i18n.T_(c, "error.err_already_in_favorites")
case errors.Is(err, ErrNotInFavorites):
return i18n.T_(c, "error.err_already_not_in_favorites")
case errors.Is(err, ErrNoRootFound):
return i18n.T_(c, "error.err_no_root_found")
@@ -249,6 +258,9 @@ func GetErrorStatus(err error) int {
errors.Is(err, ErrInvalidURLSlug),
errors.Is(err, ErrInvalidXHTML),
errors.Is(err, ErrBadPaging),
errors.Is(err, ErrProductNotFound),
errors.Is(err, ErrAlreadyInFavorites),
errors.Is(err, ErrNotInFavorites),
errors.Is(err, ErrNoRootFound),
errors.Is(err, ErrCircularDependency),
errors.Is(err, ErrStartCategoryNotFound),