From 610260357b4e9ba47b917ba150ea45357f6e6bd7 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 26 Jun 2024 04:01:43 +0700 Subject: [PATCH] refactor: delete detail error on response internal server error --- internal/admin/handler/admin_handler_impl.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/admin/handler/admin_handler_impl.go b/internal/admin/handler/admin_handler_impl.go index 7183e70..141baf4 100644 --- a/internal/admin/handler/admin_handler_impl.go +++ b/internal/admin/handler/admin_handler_impl.go @@ -51,7 +51,7 @@ func (handler *adminHandlerImpl) AddAdminHandler(c echo.Context) error { src, errOpen := file.Open() if errOpen != nil { - return helper.ErrorHandler(c, http.StatusInternalServerError, "failed to open file: "+errOpen.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "failed to open file") } defer src.Close() @@ -64,7 +64,7 @@ func (handler *adminHandlerImpl) AddAdminHandler(c echo.Context) error { if errors.Is(errUc, pkg.ErrUploadCloudinary) { return helper.ErrorHandler(c, http.StatusInternalServerError, pkg.ErrUploadCloudinary.Error()) } - return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error, detail : "+errUc.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error") } data := dto.AdminResponseRegister{ @@ -190,7 +190,7 @@ func (handler *adminHandlerImpl) UpdateAdminHandler(c echo.Context) error { } src, errOpen := reqFile.Open() if errOpen != nil { - return helper.ErrorHandler(c, http.StatusInternalServerError, "failed to open file: "+errOpen.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "failed to open file") } defer src.Close() @@ -215,7 +215,7 @@ func (handler *adminHandlerImpl) UpdateAdminHandler(c echo.Context) error { return helper.ErrorHandler(c, http.StatusBadRequest, pkg.ErrRole.Error()) } - return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error, detail : "+errUc.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error") } data := dto.AdminResponseUpdate{ @@ -236,7 +236,7 @@ func (handler *adminHandlerImpl) GetProfileAdminHandler(c echo.Context) error { if errors.Is(err, pkg.ErrAdminNotFound) { return helper.ErrorHandler(c, http.StatusNotFound, err.Error()) } - return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error, detail : "+err.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error") } data := dto.AdminResponseGetDataById{ @@ -259,7 +259,7 @@ func (handler *adminHandlerImpl) DeleteAdminHandler(c echo.Context) error { if errors.Is(err, pkg.ErrAdminNotFound) { return helper.ErrorHandler(c, http.StatusNotFound, err.Error()) } - return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error, detail : "+err.Error()) + return helper.ErrorHandler(c, http.StatusInternalServerError, "internal server error") } responseData := helper.ResponseData(http.StatusOK, "data successfully deleted", nil) return c.JSON(http.StatusOK, responseData)