Implement error-specific exit codes

This commit is contained in:
2024-08-11 20:21:01 -04:00
parent 06b9527a33
commit ed9c4e91ff
18 changed files with 102 additions and 88 deletions
+5 -5
View File
@@ -7,7 +7,7 @@ import (
"strings"
)
// TODO GPG support is a temporary feature - it will be replaced with a different encryption scheme in the future
// TODO GPG support is a temporary feature - It will be replaced with a different encryption scheme in the future
// DecryptGPG decrypts a GPG-encrypted file and returns the contents as a slice of (trimmed) strings.
func DecryptGPG(targetLocation string) []string {
@@ -18,8 +18,8 @@ func DecryptGPG(targetLocation string) []string {
enableVirtualTerminalProcessing()
if err != nil {
fmt.Println(AnsiError + "Failed to decrypt \"" + targetLocation + "\" - ensure it is a valid GPG-encrypted file and that you entered your passphrase correctly" + AnsiReset)
os.Exit(1)
fmt.Println(AnsiError + "Failed to decrypt \"" + targetLocation + "\" - Ensure it is a valid GPG-encrypted file and that you entered your passphrase correctly" + AnsiReset)
os.Exit(108)
}
outputSlice := strings.Split(string(output), "\n")
@@ -32,8 +32,8 @@ func EncryptGPG(input []string) []byte {
writeToStdin(cmd, strings.Join(input, "\n"))
encryptedBytes, err := cmd.Output()
if err != nil {
fmt.Println(AnsiError + "Failed to encrypt data - ensure that your GPG key is valid and that you have a valid GPG ID set in libmutton.ini" + AnsiReset)
os.Exit(1)
fmt.Println(AnsiError + "Failed to encrypt data - Ensure that your GPG key is valid and that you have a valid GPG ID set in libmutton.ini" + AnsiReset)
os.Exit(109)
}
return encryptedBytes
}