-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: improve error messages for better user and developer clarity
- Enhanced error messages to be more descriptive for users. - Improved error messages to aid in easier debugging.
- Loading branch information
1 parent
463bf29
commit 6dbbc7b
Showing
14 changed files
with
335 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package constants | ||
|
||
var ERROR_MESSAGES = map[string]string{ | ||
"NotFound": "The {fileName} file wasn't found in the current directory.", | ||
|
||
"Default": "Something went wrong, please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"Dependencies": "An error occurred while installing dependencies, please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"Husky": "An error has occurred during the Husky configuration process, please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"CommitLintConfig": "An error has occurred during the commitlint configuration process, please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"AddCommitLint": "An error occurred while asking if you wanna add commitlint, please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"PackageManagerSelection": "An error occurred while selecting the package manager, please try again later, if the error persists, please report it on " + ISSUES + ".", | ||
|
||
"CreateEmptyFile": "An error occurred while creating the empty file. Please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"CreateFolder": "An error occurred while creating the folder: {folderName}, please try again later, if the error persists, please report it on " + ISSUES + ".", | ||
|
||
"ReadFile": "An error has occurred while reading the {fileName} file, please try again later, if the error persists, please report it on " + ISSUES + ".", | ||
|
||
"WriteFile": "An error has occurred while writing to the {fileName} file, please try again later, if the error persists, please report it on " + ISSUES + ".", | ||
|
||
"ConfigFilesCreate": "An error occurred while creating configuration files. Please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"PublishConfirmation": "An error occurred while confirming npm publication. Please try again later, if the error persists, please report it on" + ISSUES + ".", | ||
|
||
"NpmIgnoreWrite": "An error occurred while writing to the '.npmignore' file. Please try again later, if the error persists please report it on " + ISSUES + ".", | ||
|
||
"GitHubRepoOpen": "An error occurred while opening the GitHub repository in a new browser tab. Please try again later, if the error persists please report it on" + ISSUES + ".", | ||
|
||
"JsonUnmarshal": "Replace this with an error message that's descriptive and easily understandable by any developer.", | ||
|
||
"JsonMarshal": "Replace this with an error message that's descriptive and easily understandable by any developer.", | ||
|
||
"GetWorkingDirectory": "Replace this with an error message that's descriptive and easily understandable by any developer.", | ||
|
||
"InvalidTypeForFilesToAdd": "Replace this with an error message that's descriptive and easily understandable by any developer.", | ||
|
||
"CheckingFolderOrFile": "Replace this with an error message that's descriptive and easily understandable by any developer.", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/RaulCatalinas/HuskyBC/internal/types" | ||
) | ||
|
||
type WriteMessageProps struct { | ||
Type types.MessageType | ||
Message string | ||
} | ||
|
||
func WriteMessage(props WriteMessageProps) { | ||
switch props.Type { | ||
case "success": | ||
fmt.Println("\033[32m" + props.Message + "\033[0m") | ||
|
||
case "info": | ||
fmt.Println("\033[36m" + props.Message + "\033[0m") | ||
|
||
case "error": | ||
fmt.Println("\033[31m" + props.Message + "\033[0m") | ||
|
||
case "config": | ||
fmt.Println("\033[37m" + props.Message + "\033[0m") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package utils | ||
|
||
import "github.com/RaulCatalinas/HuskyBC/internal/constants" | ||
|
||
func GetErrorMessage(error string) string { | ||
return constants.ERROR_MESSAGES[error] | ||
} |
Oops, something went wrong.