|
1 | 1 | import 'package:flutter/material.dart';
|
2 | 2 |
|
3 | 3 | import '../api/core.dart';
|
| 4 | +import '../api/exception.dart'; |
4 | 5 | import '../api/route/account.dart';
|
5 | 6 | import '../api/route/realm.dart';
|
6 | 7 | import '../api/route/users.dart';
|
@@ -155,7 +156,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
155 | 156 | return;
|
156 | 157 | }
|
157 | 158 | // TODO(#105) give more helpful feedback; see `fetchServerSettings`
|
158 |
| - // in zulip-mobile's src/message/fetchActions.js. Needs #37. |
| 159 | + // in zulip-mobile's src/message/fetchActions.js. |
159 | 160 | showErrorDialog(context: context,
|
160 | 161 | title: 'Could not connect', message: 'Failed to connect to server:\n$url');
|
161 | 162 | return;
|
@@ -279,12 +280,15 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
|
279 | 280 | try {
|
280 | 281 | result = await fetchApiKey(
|
281 | 282 | realmUrl: realmUrl, username: username, password: password);
|
282 |
| - } on Exception { // TODO(#37): distinguish API exceptions |
| 283 | + } on ApiRequestException catch (e) { |
283 | 284 | if (!context.mounted) return;
|
284 |
| - // TODO(#105) give more helpful feedback. Needs #37. The RN app is |
| 285 | + // TODO(#105) give more helpful feedback. The RN app is |
285 | 286 | // unhelpful here; we should at least recognize invalid auth errors, and
|
286 | 287 | // errors for deactivated user or realm (see zulip-mobile#4571).
|
287 |
| - showErrorDialog(context: context, title: 'Login failed'); |
| 288 | + final message = (e is ZulipApiException) |
| 289 | + ? 'The server said:\n\n${e.message}' |
| 290 | + : e.message; |
| 291 | + showErrorDialog(context: context, title: 'Login failed', message: message); |
288 | 292 | return;
|
289 | 293 | }
|
290 | 294 |
|
|
0 commit comments