From cf551539b31762ff13d1864d363c13b2e1aa0a27 Mon Sep 17 00:00:00 2001 From: Tau Date: Thu, 12 Dec 2024 03:25:58 +0100 Subject: [PATCH] handle error in rollback If the rollback fails, the error was not handled properly, since the value of response is undefined. --- cmd/rollback.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/rollback.go b/cmd/rollback.go index b3196902..1298ba35 100644 --- a/cmd/rollback.go +++ b/cmd/rollback.go @@ -61,6 +61,11 @@ func rollback(cmd *cobra.Command, args []string) error { } response, err := aBsys.Rollback(checkOnly) + if err != nil { + cmdr.Error.Println(err) + os.Exit(2) + return err + } switch response { case core.ROLLBACK_RES_YES: // NOTE: the following strings could lead to misinterpretation, with @@ -78,7 +83,7 @@ func rollback(cmd *cobra.Command, args []string) error { cmdr.Info.Println(abroot.Trans("rollback.rollbackSuccess")) os.Exit(0) case core.ROLLBACK_FAILED: - cmdr.Info.Println(abroot.Trans("rollback.rollbackFailed", err)) + cmdr.Error.Println(abroot.Trans("rollback.rollbackFailed", err)) os.Exit(1) return err }