mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
fix: handle missing expected err cases
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user