From 8ccddfeac24e30ced2f7758f30c77dbf2ae1fced Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 11 Jan 2021 19:46:20 +0100 Subject: [PATCH] Add error handling information when no endpoint is configure. Build GVA history query only if pubkey is not empty; --- lib/main.dart | 2 +- lib/ui/historyScreen.dart | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 736ccd9..6ca2db6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -22,7 +22,7 @@ T getRandomElement(List list) { } Future getRandomEndpoint() async { - // TODO: Improve implemention of getRandomEndpoint() with JSON and error handling + // TODO: Improve implemention of getRandomEndpoint() // final _json = json.decode(await getJsonEndpoints()); // print('JSON !! :'); // print(_json); diff --git a/lib/ui/historyScreen.dart b/lib/ui/historyScreen.dart index d13b15f..36cfa46 100644 --- a/lib/ui/historyScreen.dart +++ b/lib/ui/historyScreen.dart @@ -110,7 +110,7 @@ class HistoryScreenState extends State { disabledBorder: InputBorder.none, ), style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)), - historyQuery(), + if (this.pubkey != '') historyQuery(), ])); } @@ -138,11 +138,18 @@ class HistoryScreenState extends State { } if (result.hasException) { - return Text('\nErrors: \n ' + result.exception.toString()); + print('Error GVA: ' + result.exception.toString()); + return Column(children: [ + SizedBox(height: 50), + Text( + "Aucun noeud GVA valide n'a pu être trouvé.\nVeuillez réessayer ultérieurement.", + style: TextStyle(fontSize: 17.0), + ) + ]); } if (result.data == null && result.exception.toString() == null) { - return const Text('Both data and errors are null'); + return const Text('Aucune donnée à afficher.'); } final List blockchainTX =