From 8cd6a0cd03ec210cbdb534bb392d6b26fd930065 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Thu, 14 Sep 2023 14:30:33 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20new=20wrapper=20render.ErrorNotFoun?= =?UTF-8?q?d()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render/render.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/render/render.go b/render/render.go index 68ebb49..c01689b 100644 --- a/render/render.go +++ b/render/render.go @@ -34,10 +34,6 @@ func Error(c *fiber.Ctx, errors any) error { return c.Status(http.StatusBadRequest).JSON(H{"error": true, "errors": errors}) } -func ErrorPayment(c *fiber.Ctx, message string) error { - return c.Status(http.StatusPaymentRequired).JSON(H{"error": true, "errors": [1]string{message}}) -} - func ErrorCustom(c *fiber.Ctx, status int, errors any) error { if reflect.TypeOf(errors).Kind() == reflect.String { errors = [1]string{fmt.Sprintf("%v", errors)} @@ -45,6 +41,14 @@ func ErrorCustom(c *fiber.Ctx, status int, errors any) error { return c.Status(status).JSON(H{"error": true, "errors": errors}) } +func ErrorNotFound(c *fiber.Ctx, errors any) error { + return ErrorCustom(c, http.StatusNotFound, errors) +} + +func ErrorPayment(c *fiber.Ctx, errors any) error { + return ErrorCustom(c, http.StatusPaymentRequired, errors) +} + func Unauthorized(c *fiber.Ctx) error { return c.Status(http.StatusUnauthorized).JSON(H{"error": true, "errors": [1]string{"Unauthorized"}}) }