Skip to content

Commit

Permalink
refactor: use fiber constant for error message (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio authored Mar 7, 2024
1 parent fbc80f7 commit 758a3ae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions internal/handlers/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -118,7 +122,7 @@ func (p *Log) PatchLog(ctx *fiber.Ctx) error {
return common.Error(fiber.StatusNotFound, errMsg, "Log was not found")
}

return common.Error(fiber.StatusInternalServerError, errMsg, "internal server error")
return common.Error(fiber.StatusInternalServerError, errMsg, fiber.ErrInternalServerError.Message)
}

log.Message = logReq.Message
Expand Down
8 changes: 6 additions & 2 deletions internal/handlers/publishers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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)
Expand Down Expand Up @@ -155,7 +159,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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/software.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (p *Software) PatchSoftware(ctx *fiber.Ctx) error { //nolint:funlen,cyclop
return common.Error(fiber.StatusNotFound, errMsg, "Software was not found")
}

return common.Error(fiber.StatusInternalServerError, errMsg, err.Error())
return common.Error(fiber.StatusInternalServerError, errMsg, fiber.ErrInternalServerError.Message)
}

if err := common.ValidateRequestEntity(ctx, &softwareReq, errMsg); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion internal/handlers/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 758a3ae

Please sign in to comment.