From b226409cafd5df9ab3f0e38461b0f03a653fce45 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 17 Sep 2024 02:06:04 +0800 Subject: [PATCH] :bug: Fix fix fix --- pkg/internal/server/api/subscriptions_api.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/internal/server/api/subscriptions_api.go b/pkg/internal/server/api/subscriptions_api.go index 931990e..289214a 100644 --- a/pkg/internal/server/api/subscriptions_api.go +++ b/pkg/internal/server/api/subscriptions_api.go @@ -23,7 +23,9 @@ func getSubscriptionOnUser(c *fiber.Ctx) error { subscription, err := services.GetSubscriptionOnUser(user, otherUser) if err != nil { - return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("unable to get subscription: %v", err)) + return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to get subscription: %v", err)) + } else if subscription == nil { + return fiber.NewError(fiber.StatusNotFound, "subscription does not exist") } return c.JSON(subscription) @@ -43,7 +45,9 @@ func getSubscriptionOnTag(c *fiber.Ctx) error { subscription, err := services.GetSubscriptionOnTag(user, tag) if err != nil { - return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("unable to get subscription: %v", err)) + return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to get subscription: %v", err)) + } else if subscription == nil { + return fiber.NewError(fiber.StatusNotFound, "subscription does not exist") } return c.JSON(subscription) @@ -63,7 +67,9 @@ func getSubscriptionOnCategory(c *fiber.Ctx) error { subscription, err := services.GetSubscriptionOnCategory(user, category) if err != nil { - return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("unable to get subscription: %v", err)) + return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to get subscription: %v", err)) + } else if subscription == nil { + return fiber.NewError(fiber.StatusNotFound, "subscription does not exist") } return c.JSON(subscription)