From e9ba7bccbd37be1ccfc4851b9106d69b1a3fc341 Mon Sep 17 00:00:00 2001 From: Maarten Everts Date: Fri, 4 Sep 2020 16:11:32 +0200 Subject: [PATCH] Add error handling for when connection to socket fails --- cmd/signald-cli/cmd/root.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/signald-cli/cmd/root.go b/cmd/signald-cli/cmd/root.go index de24eb8..a943e55 100644 --- a/cmd/signald-cli/cmd/root.go +++ b/cmd/signald-cli/cmd/root.go @@ -17,6 +17,7 @@ package cmd import ( "fmt" + "log" "os" "github.com/spf13/cobra" @@ -50,7 +51,11 @@ func init() { RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)") RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file") s = &signald.Signald{SocketPath: socketPath} - s.Connect() + err := s.Connect() + if err != nil { + log.Fatal(err) + } + } // initConfig reads in config file and ENV variables if set.