From 8d7282018a6fb09de5c59bb793014f0990980fb4 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sat, 22 May 2021 18:29:38 -0400 Subject: [PATCH] autojoin: bubble error up --- autojoin/cmd.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/autojoin/cmd.go b/autojoin/cmd.go index 1a7b513..4622219 100644 --- a/autojoin/cmd.go +++ b/autojoin/cmd.go @@ -2,7 +2,6 @@ package autojoin import ( "fmt" - "os" "github.com/rwxrob/cmdtab" @@ -19,21 +18,19 @@ func init() { if len(args) != 0 { return x.UsageError() } - autojoin() - return nil + return autojoin() } } -func autojoin() { +func autojoin() error { data, err := shared.GetAuthInfo() if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) + return err } client, err := mautrix.NewClient(data.Homeserver, data.UserID, data.AccessToken) if err != nil { - panic(err) + return err } syncer := client.Syncer.(*mautrix.DefaultSyncer) @@ -58,8 +55,5 @@ func autojoin() { }) fmt.Println("Looking for rooms to join...") - err = client.Sync() - if err != nil { - panic(err) - } + return client.Sync() } -- 2.38.4