From 827fba21645b378b4982e589d9cc677a0a2d61cb Mon Sep 17 00:00:00 2001 From: link Date: Thu, 9 Feb 2023 17:29:33 +0800 Subject: [PATCH] Add error logs (#879) --- pkg/utils/httper/drive.go | 2 ++ route/v1/storage.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/utils/httper/drive.go b/pkg/utils/httper/drive.go index 13db91b89..28b4c1ba0 100644 --- a/pkg/utils/httper/drive.go +++ b/pkg/utils/httper/drive.go @@ -92,9 +92,11 @@ func Unmount(mountPoint string) error { "mountPoint": mountPoint, }).Post("/mount/unmount") if err != nil { + logger.Error("when unmount", zap.Error(err)) return err } if res.StatusCode() != 200 { + logger.Error("then unmount failed", zap.Any("res", res.Body())) return fmt.Errorf("unmount failed") } logger.Info("unmount then", zap.Any("res", res.Body())) diff --git a/route/v1/storage.go b/route/v1/storage.go index 0bfea8aaf..334b425ba 100644 --- a/route/v1/storage.go +++ b/route/v1/storage.go @@ -84,12 +84,12 @@ func DeleteStorage(c *gin.Context) { c.ShouldBind(&json) mountPoint := json["mount_point"] if mountPoint == "" { - c.JSON(common_err.SUCCESS, model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: "mount_point is empty"}) + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: "mount_point is empty"}) return } err := service.MyService.Storage().UnmountStorage(mountPoint) if err != nil { - c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()}) + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()}) return } service.MyService.Storage().DeleteConfigByName(strings.ReplaceAll(mountPoint, "/mnt/", ""))