Skip to content

Commit 1b084dc

Browse files
committed
Added error message
it's ugly but it's just for debugging purposes
1 parent 1d68115 commit 1b084dc

File tree

5 files changed

+107
-5
lines changed

5 files changed

+107
-5
lines changed

lib/kdecole-api/client.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class Client {
247247
if (res['success'] == true) {
248248
return Client(res['authtoken']);
249249
} else {
250-
throw Error();
250+
throw BadCredentialsException();
251251
}
252252
}
253253

@@ -260,6 +260,8 @@ class Client {
260260
}
261261
}
262262

263+
class BadCredentialsException implements Exception {}
264+
263265
enum HTTPRequestMethod { get, put, delete }
264266

265267
/// A subset of the different actions allowed by the API

lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ void main() async {
1717
stdout.writeln('Database URL: ' + dbPath);
1818
Global.storage = const FlutterSecureStorage();
1919
//Comment this out in production
20-
//await deleteDatabase(dbPath);
21-
//Global.storage!.deleteAll();
20+
await deleteDatabase(dbPath);
21+
Global.storage!.deleteAll();
2222
try {
2323
Global.token = await Global.storage!.read(key: 'token');
2424
} on PlatformException catch (_) {

lib/screens/login.dart

+17-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,25 @@ class LoginState extends State<Login> {
4747
Global.client =
4848
await Client.login(_unameController.text, _pwdController.text);
4949
widget.onLogin();
50-
} catch (e) {
50+
} on BadCredentialsException catch (_) {
5151
ScaffoldMessenger.of(context).showSnackBar(
5252
const SnackBar(content: Text('Mauvais identifiant/mot de passe')));
53+
} catch (e, st) {
54+
Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
55+
return Scaffold(
56+
appBar: AppBar(
57+
title: Text('Erreur'),
58+
),
59+
body: SingleChildScrollView(
60+
child: Column(
61+
children: [
62+
Text(e.toString()),
63+
Text(st.toString()),
64+
],
65+
),
66+
),
67+
);
68+
}));
5369
}
5470
}
5571
}

logo.svg

+84
Loading

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 1.0.0+1
18+
version: 0.1.1
1919

2020
environment:
2121
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)