Assign error-specific exit codes to constants

This commit is contained in:
2024-08-13 20:48:20 -04:00
parent a1c9827c04
commit 4c54349b39
17 changed files with 90 additions and 92 deletions
+4 -4
View File
@@ -16,7 +16,7 @@ func copyField(executableName, copySubject string) {
err := cmd.Run()
if err != nil {
fmt.Println(AnsiError+"Failed to copy to clipboard:", err.Error()+AnsiReset)
os.Exit(110)
os.Exit(ErrorClipboard)
}
// launch clipboard clearing process if executableName is provided
@@ -26,7 +26,7 @@ func copyField(executableName, copySubject string) {
err = cmd.Start()
if err != nil {
fmt.Println(AnsiError + "Failed to launch automated clipboard clearing process - Does this libmutton implementation support the \"clipclear\" argument?" + AnsiReset)
os.Exit(110)
os.Exit(ErrorClipboard)
}
Exit(0) // only exit if clipboard clearing process is launched, otherwise assume continuous clipboard refresh
}
@@ -40,7 +40,7 @@ func clipClear(oldContents string) {
newContents, err := cmd.Output()
if err != nil {
fmt.Println(AnsiError+"Failed to read clipboard contents:", err.Error()+AnsiReset)
os.Exit(110)
os.Exit(ErrorClipboard)
}
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
@@ -48,7 +48,7 @@ func clipClear(oldContents string) {
err = cmd.Run()
if err != nil {
fmt.Println(AnsiError+"Failed to clear clipboard:", err.Error()+AnsiReset)
os.Exit(110)
os.Exit(ErrorClipboard)
}
}
os.Exit(0) // use os.Exit instead of core.Exit, as this function runs out of a background subprocess that is invisible to the user (will never appear in GUI/TUI environment)