Skip to content

Commit fc94d99

Browse files
committed
store [nfc]: Move some declarations up out of a switch case
And rethrow AccountNotFoundExceptions in an explicit `on` block, rather than in the `default` case of this `switch`. (Otherwise the account-exists check would throw.)
1 parent 0922ca5 commit fc94d99

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/model/store.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,16 @@ abstract class GlobalStore extends ChangeNotifier {
186186
final PerAccountStore store;
187187
try {
188188
store = await doLoadPerAccount(accountId);
189+
} on AccountNotFoundException {
190+
rethrow;
189191
} catch (e) {
192+
final account = getAccount(accountId);
193+
assert(account != null); // doLoadPerAccount would have thrown AccountNotFoundException
194+
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
190195
switch (e) {
191196
case HttpException(httpStatus: 401):
192197
// The API key is invalid and the store can never be loaded
193198
// unless the user retries manually.
194-
final account = getAccount(accountId);
195-
assert(account != null); // doLoadPerAccount would have thrown AccountNotFoundException
196-
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
197199
reportErrorToUserModally(
198200
zulipLocalizations.errorCouldNotConnectTitle,
199201
message: zulipLocalizations.errorInvalidApiKeyMessage(

0 commit comments

Comments
 (0)