aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorDaniel Bridges <bridges2@gmail.com>2019-07-09 17:04:21 -0700
committerDrew DeVault <sir@cmpwn.com>2019-07-10 13:21:38 -0400
commit217e85a55d0c1047bef1e2bc41783ccd4629bfc1 (patch)
tree5e06a60ccc27e59e4eef63315cea5065b5c3e8c6 /widgets/msgviewer.go
parent3f30c27bb31f26ca639b7a87d54a7c522bbe8be0 (diff)
downloadaerc-217e85a55d0c1047bef1e2bc41783ccd4629bfc1.tar.gz
Fix crashes when operating on empty folder (#216)
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index f6bef2d8..f15fbae4 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -2,6 +2,7 @@ package widgets
import (
"bufio"
+ "errors"
"fmt"
"io"
"os/exec"
@@ -211,8 +212,11 @@ func (mv *MessageViewer) SelectedAccount() *AccountView {
return mv.acct
}
-func (mv *MessageViewer) SelectedMessage() *models.MessageInfo {
- return mv.msg
+func (mv *MessageViewer) SelectedMessage() (*models.MessageInfo, error) {
+ if mv.msg == nil {
+ return nil, errors.New("no message selected")
+ }
+ return mv.msg, nil
}
func (mv *MessageViewer) ToggleHeaders() {