From b3b7b7048083af8da9cc6e78e1a4cb73988f6798 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 4 Jun 2020 18:43:51 +0300 Subject: Improve errors in crypto stuff --- matrix/crypto.go | 6 ++++-- matrix/matrix.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'matrix') diff --git a/matrix/crypto.go b/matrix/crypto.go index 8eab355..158a1f2 100644 --- a/matrix/crypto.go +++ b/matrix/crypto.go @@ -21,6 +21,8 @@ package matrix import ( "path/filepath" + "github.com/pkg/errors" + "maunium.net/go/mautrix/crypto" "maunium.net/go/gomuks/debug" @@ -51,12 +53,12 @@ func isBadEncryptError(err error) bool { func (c *Container) initCrypto() error { cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.DataDir, "crypto.gob")) if err != nil { - return err + return errors.Wrap(err, "failed to open crypto store") } c.crypto = crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms) err = c.crypto.Load() if err != nil { - return err + return errors.Wrap(err, "failed to create olm machine") } return nil } diff --git a/matrix/matrix.go b/matrix/matrix.go index 1407125..43020f9 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -115,7 +115,7 @@ func (c *Container) InitClient() error { var err error c.client, err = mautrix.NewClient(c.config.HS, mxid, accessToken) if err != nil { - return err + return errors.Wrap(err, "failed to create mautrix client") } c.client.UserAgent = fmt.Sprintf("gomuks %s (with mautrix-go %s)", c.gmx.Version(), mautrix.Version) c.client.Logger = mxLogger{} @@ -123,7 +123,7 @@ func (c *Container) InitClient() error { err = c.initCrypto() if err != nil { - return err + return errors.Wrap(err, "failed to initialize crypto") } if c.history == nil { -- cgit v1.2.3