From 48bbda82a578907aa05e5a29dfc6ecc7189a6bc2 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Mon, 10 Oct 2022 19:26:24 +0200 Subject: [PATCH] refactor: use fiber constant for error message --- internal/handlers/logs.go | 12 ++++++++++-- internal/handlers/publishers.go | 8 ++++++-- internal/handlers/software.go | 6 +++++- internal/handlers/webhooks.go | 6 +++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/internal/handlers/logs.go b/internal/handlers/logs.go index 357146b..295ca75 100644 --- a/internal/handlers/logs.go +++ b/internal/handlers/logs.go @@ -76,7 +76,11 @@ func (p *Log) GetLog(ctx *fiber.Ctx) error { return common.Error(fiber.StatusNotFound, "can't get Log", "Log was not found") } - return common.Error(fiber.StatusInternalServerError, "can't get Log", "internal server error") + return common.Error( + fiber.StatusInternalServerError, + "can't get Log", + fiber.ErrInternalServerError.Message, + ) } return ctx.JSON(&log) @@ -122,7 +126,11 @@ func (p *Log) PatchLog(ctx *fiber.Ctx) error { return common.Error(fiber.StatusNotFound, "can't update Log", "Log was not found") } - return common.Error(fiber.StatusInternalServerError, "can't update Log", "internal server error") + return common.Error( + fiber.StatusInternalServerError, + "can't update Log", + fiber.ErrInternalServerError.Message, + ) } log.Message = logReq.Message diff --git a/internal/handlers/publishers.go b/internal/handlers/publishers.go index 4faf6f5..e551db5 100644 --- a/internal/handlers/publishers.go +++ b/internal/handlers/publishers.go @@ -77,7 +77,11 @@ func (p *Publisher) GetPublisher(ctx *fiber.Ctx) error { return common.Error(fiber.StatusNotFound, "can't get Publisher", "Publisher was not found") } - return common.Error(fiber.StatusInternalServerError, "can't get Publisher", "internal server error") + return common.Error( + fiber.StatusInternalServerError, + "can't get Publisher", + fiber.ErrInternalServerError.Message, + ) } return ctx.JSON(&publisher) @@ -127,7 +131,7 @@ func (p *Publisher) PostPublisher(ctx *fiber.Ctx) error { default: return common.Error(fiber.StatusInternalServerError, "can't create Publisher", - "internal server error") + fiber.ErrInternalServerError.Message) } } diff --git a/internal/handlers/software.go b/internal/handlers/software.go index 84742d9..d94f782 100644 --- a/internal/handlers/software.go +++ b/internal/handlers/software.go @@ -199,7 +199,11 @@ func (p *Software) PatchSoftware(ctx *fiber.Ctx) error { //nolint:cyclop // most return common.Error(fiber.StatusNotFound, "can't update Software", "Software was not found") } - return common.Error(fiber.StatusInternalServerError, "can't update Software", "internal server error") + return common.Error( + fiber.StatusInternalServerError, + "can't update Software", + fiber.ErrInternalServerError.Message, + ) } if err := ctx.BodyParser(softwareReq); err != nil { diff --git a/internal/handlers/webhooks.go b/internal/handlers/webhooks.go index 69ced44..9d08358 100644 --- a/internal/handlers/webhooks.go +++ b/internal/handlers/webhooks.go @@ -28,7 +28,11 @@ func (p *Webhook[T]) GetWebhook(ctx *fiber.Ctx) error { return common.Error(fiber.StatusNotFound, "can't get Webhook", "Webhook was not found") } - return common.Error(fiber.StatusInternalServerError, "can't get Webhook", "internal server error") + return common.Error( + fiber.StatusInternalServerError, + "can't get Webhook", + fiber.ErrInternalServerError.Message, + ) } return ctx.JSON(&webhook)