aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/account/view.go6
-rw-r--r--commands/msg/delete.go6
-rw-r--r--commands/msgview/next.go6
-rw-r--r--lib/messageview.go18
-rw-r--r--widgets/msglist.go6
5 files changed, 31 insertions, 11 deletions
diff --git a/commands/account/view.go b/commands/account/view.go
index d1b90cef..b421666b 100644
--- a/commands/account/view.go
+++ b/commands/account/view.go
@@ -39,7 +39,11 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
lib.NewMessageStoreView(msg, store, aerc.DecryptKeys,
- func(view lib.MessageView) {
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
viewer := widgets.NewMessageViewer(acct, aerc.Config(), view)
aerc.NewTab(viewer, msg.Envelope.Subject)
})
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 313e3ea9..4bda8b98 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -66,7 +66,11 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
lib.NewMessageStoreView(next, store, aerc.DecryptKeys,
- func(view lib.MessageView) {
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view)
aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject)
})
diff --git a/commands/msgview/next.go b/commands/msgview/next.go
index c218ad53..978cf10f 100644
--- a/commands/msgview/next.go
+++ b/commands/msgview/next.go
@@ -38,7 +38,11 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
lib.NewMessageStoreView(nextMsg, store, aerc.DecryptKeys,
- func(view lib.MessageView) {
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view)
aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject)
})
diff --git a/lib/messageview.go b/lib/messageview.go
index 59a1af6b..384a9472 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -59,7 +59,7 @@ type MessageStoreView struct {
func NewMessageStoreView(messageInfo *models.MessageInfo,
store *MessageStore, decryptKeys openpgp.PromptFunction,
- cb func(MessageView)) {
+ cb func(MessageView, error)) {
msv := &MessageStoreView{messageInfo, store,
nil, nil, messageInfo.BodyStructure}
@@ -69,26 +69,30 @@ func NewMessageStoreView(messageInfo *models.MessageInfo,
reader := fm.Content.Reader
pgpReader, err := pgpmail.Read(reader, Keyring, decryptKeys, nil)
if err != nil {
- panic(err)
+ cb(nil, err)
+ return
}
msv.message, err = ioutil.ReadAll(pgpReader.MessageDetails.UnverifiedBody)
if err != nil {
- panic(err)
+ cb(nil, err)
+ return
}
decrypted, err := message.Read(bytes.NewBuffer(msv.message))
if err != nil {
- panic(err)
+ cb(nil, err)
+ return
}
bs, err := lib.ParseEntityStructure(decrypted)
if err != nil {
- panic(err)
+ cb(nil, err)
+ return
}
msv.bodyStructure = bs
msv.details = pgpReader.MessageDetails
- cb(msv)
+ cb(msv, nil)
})
} else {
- cb(msv)
+ cb(msv, nil)
}
store.Read([]uint32{messageInfo.Uid}, true, nil)
}
diff --git a/widgets/msglist.go b/widgets/msglist.go
index f36901f6..5aedb446 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -166,7 +166,11 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) {
return
}
lib.NewMessageStoreView(msg, store, ml.aerc.DecryptKeys,
- func(view lib.MessageView) {
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ ml.aerc.PushError(err.Error())
+ return
+ }
viewer := NewMessageViewer(acct, ml.aerc.Config(), view)
ml.aerc.NewTab(viewer, msg.Envelope.Subject)
})