Skip to content

Commit

Permalink
refactor: use fiber constant for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio committed Oct 10, 2022
1 parent 5592e82 commit 48bbda8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
12 changes: 10 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 @@ -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
Expand Down
8 changes: 6 additions & 2 deletions internal/handlers/publishers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 5 additions & 1 deletion internal/handlers/software.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 48bbda8

Please sign in to comment.