mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-31 22:36:41 -04:00
Assign error-specific exit codes to constants
This commit is contained in:
+4
-4
@@ -17,7 +17,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
|
||||
@@ -27,7 +27,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
|
||||
}
|
||||
@@ -41,7 +41,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") {
|
||||
@@ -50,7 +50,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)
|
||||
|
||||
Reference in New Issue
Block a user