Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use fiber constant for error message #168

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading