From 6b744b71f878a8dc6673c52bb36e6ab6d00eeb63 Mon Sep 17 00:00:00 2001 From: Raul Catalinas <105791463+RaulCatalinas@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:08:42 +0100 Subject: [PATCH] feat: add error messages to "process.go" - Replaced placeholders with proper error messages in "error_messages/process.go". - Closes #79. --- internal/enums/errors.go | 1 - internal/error_messages/process.go | 8 +++----- internal/utils/npm.go | 11 ----------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/internal/enums/errors.go b/internal/enums/errors.go index 6a24a4c..c3aba1b 100644 --- a/internal/enums/errors.go +++ b/internal/enums/errors.go @@ -24,7 +24,6 @@ const ( const ( JsonUnmarshalError ProcessError = "JsonUnmarshal" JsonMarshalError ProcessError = "JsonMarshal" - GetWorkingDirectoryError ProcessError = "GetWorkingDirectory" InvalidTypeForFilesToAddError ProcessError = "InvalidTypeForFilesToAdd" DependenciesError ProcessError = "Dependencies" GitHubRepoOpenError ProcessError = "GitHubRepoOpen" diff --git a/internal/error_messages/process.go b/internal/error_messages/process.go index 083a3a2..9131b9a 100644 --- a/internal/error_messages/process.go +++ b/internal/error_messages/process.go @@ -3,13 +3,11 @@ package error_messages import "github.com/RaulCatalinas/HuskyBC/internal/enums" var PROCESS_ERROR_MESSAGES = map[enums.ProcessError]string{ - enums.JsonUnmarshalError: "Replace this with an error message that's descriptive and easily understandable by any developer.", + enums.JsonUnmarshalError: generateErrorMessage("unmarshalling JSON data"), - enums.JsonMarshalError: "Replace this with an error message that's descriptive and easily understandable by any developer.", + enums.JsonMarshalError: generateErrorMessage("marshalling JSON data with indentation"), - enums.GetWorkingDirectoryError: "Replace this with an error message that's descriptive and easily understandable by any developer.", - - enums.InvalidTypeForFilesToAddError: "Replace this with an error message that's descriptive and easily understandable by any developer.", + enums.InvalidTypeForFilesToAddError: generateErrorMessage("adding files to .npmignore with an invalid type"), enums.DependenciesError: generateErrorMessage("installing dependencies"), diff --git a/internal/utils/npm.go b/internal/utils/npm.go index 1ebe9d1..0d8980a 100644 --- a/internal/utils/npm.go +++ b/internal/utils/npm.go @@ -26,17 +26,6 @@ func modifyNpmIgnore(filesToAdd interface{}) { Message: "Writing in the file \".npmignore\"...", }) - _, err := os.Getwd() - - if err != nil { - WriteMessage(WriteMessageProps{ - Type: enums.MessageTypeError, - Message: errorMessages.PROCESS_ERROR_MESSAGES[enums.GetWorkingDirectoryError], - }) - - os.Exit(1) - } - CreateFolderOrFileIfNotExists(constants.PATH_DIR_NPMIGNORE, false) data := readFile(constants.PATH_DIR_NPMIGNORE)