fix: handle missing expected err cases

This commit is contained in:
2025-11-30 20:08:31 +00:00
parent 6c61cbe1fd
commit 3e96c42c4a
3 changed files with 13 additions and 0 deletions

View File

@@ -55,6 +55,12 @@ func (h *HTTPHandler) Create(c *fiber.Ctx) error {
if errors.Is(err, ErrNotFound) {
return c.SendStatus(fiber.StatusNotFound)
}
if errors.Is(err, ErrParentNotDirectory) {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Parent is not a directory"})
}
if errors.Is(err, ErrConflict) {
return c.Status(fiber.StatusConflict).JSON(fiber.Map{"error": "A file with this name already exists"})
}
return httperr.Internal(err)
}
@@ -102,6 +108,9 @@ func (h *HTTPHandler) Update(c *fiber.Ctx) error {
if errors.Is(err, ErrNotFound) {
return c.SendStatus(fiber.StatusNotFound)
}
if errors.Is(err, ErrContentNotUploaded) {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Content has not been uploaded"})
}
return httperr.Internal(err)
}
return c.JSON(upload)