mirror of
https://github.com/rwinkhart/go-boilerplate.git
synced 2026-08-27 20:36:29 -04:00
Always hard exit in PrintError(); do not pointlessly return the error code in soft exit
This commit is contained in:
+2
-2
@@ -3,6 +3,6 @@
|
|||||||
package back
|
package back
|
||||||
|
|
||||||
// Exit (soft) is meant to be used in interactive implementations (GUIs/TUIs) to keep the program running after an operation.
|
// Exit (soft) is meant to be used in interactive implementations (GUIs/TUIs) to keep the program running after an operation.
|
||||||
func Exit(code int) int {
|
func Exit(code int) {
|
||||||
return code
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-7
@@ -9,13 +9,8 @@ import (
|
|||||||
|
|
||||||
// PrintError prints an error message in the MUTN format and exits with the specified exit code.
|
// PrintError prints an error message in the MUTN format and exits with the specified exit code.
|
||||||
// Requires: message (the error message to print),
|
// Requires: message (the error message to print),
|
||||||
// exitCode (the exit code to use),
|
// exitCode (the exit code to use)
|
||||||
// forceHardExit (if true, exit immediately; if false, allow soft exit for interactive clients).
|
func PrintError(message string, exitCode int) {
|
||||||
func PrintError(message string, exitCode int, forceHardExit bool) {
|
|
||||||
fmt.Println(back.AnsiError + message + back.AnsiReset)
|
fmt.Println(back.AnsiError + message + back.AnsiReset)
|
||||||
if forceHardExit {
|
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
} else {
|
|
||||||
back.Exit(exitCode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user