about summary refs log tree commit diff stats
path: root/widgets/aerc.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-08-08 11:38:38 +0200
committerReto Brunner <reto@labrat.space>2020-08-10 08:00:34 +0200
commit2d7a8707257eec2b9f0ff41772cfd8dab4f1201e (patch)
tree257436ae151d923cf80aec0382f16b9fa03bbdae /widgets/aerc.go
parentc3c982c3ec0f9702047e0e09d667bbd70a33103c (diff)
downloadaerc-2d7a8707257eec2b9f0ff41772cfd8dab4f1201e.tar.gz
show error if account view creation fails
This can happen for example if aerc is compiled without notmuch support but the
notmuch worker is requested.
Pushing a status message isn't good enough, as this gets overridden pretty
quickly if one has multiple accounts configured.
So we show a fullscreen error instead.
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r--widgets/aerc.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 692e00d..acdd8b4 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -84,9 +84,13 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
 	conf.Triggers.ExecuteCommand = cmd
 
 	for i, acct := range conf.Accounts {
-		view := NewAccountView(aerc, conf, &conf.Accounts[i], logger, aerc)
-		aerc.accounts[acct.Name] = view
-		tabs.Add(view, acct.Name)
+		view, err := NewAccountView(aerc, conf, &conf.Accounts[i], logger, aerc)
+		if err != nil {
+			tabs.Add(errorScreen(err.Error(), conf.Ui), acct.Name)
+		} else {
+			aerc.accounts[acct.Name] = view
+			tabs.Add(view, acct.Name)
+		}
 	}
 
 	if len(conf.Accounts) == 0 {
@@ -609,3 +613,20 @@ func (aerc *Aerc) DecryptKeys(keys []openpgp.Key, symmetric bool) (b []byte, err
 	}
 	return nil, err
 }
+
+// errorScreen is a widget that draws an error in the middle of the context
+func errorScreen(s string, conf config.UIConfig) ui.Drawable {
+	errstyle := conf.GetStyle(config.STYLE_ERROR)
+	text := ui.NewText(s, errstyle).Strategy(ui.TEXT_CENTER)
+	grid := ui.NewGrid().Rows([]ui.GridSpec{
+		{ui.SIZE_WEIGHT, ui.Const(1)},
+		{ui.SIZE_EXACT, ui.Const(1)},
+		{ui.SIZE_WEIGHT, ui.Const(1)},
+	}).Columns([]ui.GridSpec{
+		{ui.SIZE_WEIGHT, ui.Const(1)},
+	})
+	grid.AddChild(ui.NewFill(' ')).At(0, 0)
+	grid.AddChild(text).At(1, 0)
+	grid.AddChild(ui.NewFill(' ')).At(2, 0)
+	return grid
+}