aerc/widgets
Koni Marti 4d3156ddf1 aerc: fix panic when backend is unknown
A panic occurs when an unknown backend is used. This regression was
introduced by commit a34be9eb36 ("status: use contextual ui styleset
for statusline"). Before this commit, an error screen for the unknown
backend was displayed. The contextual ui requires an account-specific ui
config but when the backend throws an error in the constructor of the
account view, the call to aerc.SelectedAccountUiConfig() panics:

panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/logging.PanicHandler()
        git.sr.ht/~rjarry/aerc/logging/panic-logger.go:47 +0x6de
panic({0xa42760, 0xc000427068})
        runtime/panic.go:844 +0x258
git.sr.ht/~rjarry/aerc/widgets.(*Aerc).SelectedTab(...)
        git.sr.ht/~rjarry/aerc/widgets/aerc.go:337
git.sr.ht/~rjarry/aerc/widgets.(*Aerc).SelectedAccount(...)
        git.sr.ht/~rjarry/aerc/widgets/aerc.go:313
git.sr.ht/~rjarry/aerc/widgets.(*Aerc).SelectedAccountUiConfig(0x9c99c0?)
        git.sr.ht/~rjarry/aerc/widgets/aerc.go:329 +0xe9
git.sr.ht/~rjarry/aerc/widgets.(*StatusLine).uiConfig(...)
        git.sr.ht/~rjarry/aerc/widgets/status.go:112
git.sr.ht/~rjarry/aerc/widgets.(*StatusLine).SetError(0xc00043a420,
{0xc000429220, 0x1b})
        git.sr.ht/~rjarry/aerc/widgets/status.go:66 +0x4d
git.sr.ht/~rjarry/aerc/widgets.(*Aerc).SetError(0xa7c4d7?,
{0xc000429220?, 0xc00035ec80?})
        git.sr.ht/~rjarry/aerc/widgets/aerc.go:440 +0x25
git.sr.ht/~rjarry/aerc/widgets.NewAccountView(0xc000502000,
0xc0002b8000, 0xc000440700, 0xc000098960, {0xb72d58?, 0xc000502000},
0xc00042c3c0)
        git.sr.ht/~rjarry/aerc/widgets/account.go:75 +0xafa
git.sr.ht/~rjarry/aerc/widgets.NewAerc(0xc0002b8000, 0xc000098960,
{0xb73300?, 0xc0004380f0}, 0xc000420108, 0xc000430630, {0xb71580?,
0xfae9a0}, 0x2?)
        git.sr.ht/~rjarry/aerc/widgets/aerc.go:92 +0x8e5
main.main()
        git.sr.ht/~rjarry/aerc/aerc.go:176 +0x5ff

This can be reproduced by adding the following as the first (!) backend
to your accounts.conf:

[test]
source = test
from = test

Expected behavior would be to see the error screen with the "Unknown
Backend" text.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:34:47 +02:00
..
account-wizard.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
account.go perf: reduce calls to GetUiConfig 2022-07-03 21:32:24 +02:00
aerc.go aerc: fix panic when backend is unknown 2022-07-10 20:34:47 +02:00
authinfo.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
common.go go.mod: change base git url 2021-11-05 10:21:45 +01:00
compose.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
dirlist.go perf: reduce calls to GetUiConfig 2022-07-03 21:32:24 +02:00
dirtree.go dirlist: fix panic when disconnecting with dirlist-tree=false 2022-06-07 18:01:25 +02:00
exline.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
getpasswd.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
headerlayout.go go.mod: change base git url 2021-11-05 10:21:45 +01:00
msglist.go perf: reduce calls to GetUiConfig 2022-07-03 21:32:24 +02:00
msgviewer.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
pgpinfo.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
providesmessage.go msgviewer: open http links from messages 2022-06-14 22:12:48 +02:00
scrollable.go scrollable: extract scrolling behavior for reuse 2022-03-03 21:11:05 +01:00
selector.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
spinner.go logging: added a log on panic 2022-03-23 20:56:09 +01:00
status.go uiconfig: use pointer references to uiConfig 2022-07-03 21:32:18 +02:00
tabhost.go Implement style configuration. 2020-08-06 21:42:06 +02:00
terminal.go terminal: fix deadlock with finer-grained locking 2022-05-25 22:18:26 +02:00