Improve errors in crypto stuff

This commit is contained in:
Tulir Asokan 2020-06-04 18:43:51 +03:00
parent 996fe62a21
commit b3b7b70480
2 changed files with 6 additions and 4 deletions

View File

@ -21,6 +21,8 @@ package matrix
import ( import (
"path/filepath" "path/filepath"
"github.com/pkg/errors"
"maunium.net/go/mautrix/crypto" "maunium.net/go/mautrix/crypto"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
@ -51,12 +53,12 @@ func isBadEncryptError(err error) bool {
func (c *Container) initCrypto() error { func (c *Container) initCrypto() error {
cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.DataDir, "crypto.gob")) cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.DataDir, "crypto.gob"))
if err != nil { 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) c.crypto = crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
err = c.crypto.Load() err = c.crypto.Load()
if err != nil { if err != nil {
return err return errors.Wrap(err, "failed to create olm machine")
} }
return nil return nil
} }

View File

@ -115,7 +115,7 @@ func (c *Container) InitClient() error {
var err error var err error
c.client, err = mautrix.NewClient(c.config.HS, mxid, accessToken) c.client, err = mautrix.NewClient(c.config.HS, mxid, accessToken)
if err != nil { 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.UserAgent = fmt.Sprintf("gomuks %s (with mautrix-go %s)", c.gmx.Version(), mautrix.Version)
c.client.Logger = mxLogger{} c.client.Logger = mxLogger{}
@ -123,7 +123,7 @@ func (c *Container) InitClient() error {
err = c.initCrypto() err = c.initCrypto()
if err != nil { if err != nil {
return err return errors.Wrap(err, "failed to initialize crypto")
} }
if c.history == nil { if c.history == nil {