From 257869bddb8b1eb735e7e8f1978082f7b0f45782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20H=C3=B8rgreen?= Date: Thu, 29 Aug 2024 13:00:21 +0200 Subject: [PATCH] error handle --- cmd/alter.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/alter.go b/cmd/alter.go index 297357f..9174896 100644 --- a/cmd/alter.go +++ b/cmd/alter.go @@ -51,10 +51,22 @@ var alterCmd = &cobra.Command{ tx := conn.BeginTransaction() - conn.AddRole(tx, username, add_roles) - conn.RemoveRole(tx, username, remove_roles) + err = conn.AddRole(tx, username, add_roles) + if err != nil { + cmd.Println(fmt.Errorf("could not add role: %v", err)) + os.Exit(1) + } + err = conn.RemoveRole(tx, username, remove_roles) + if err != nil { + cmd.Println(fmt.Errorf("could not remove role: %v", err)) + os.Exit(1) + } - tx.Commit() + err = tx.Commit() + if err != nil { + cmd.Println(fmt.Errorf("could not commit: %v", err)) + os.Exit(1) + } output := getOutputType(cmd) if output == OutputTypeJson {