Skip to content

Commit b03697b

Browse files
jgfosterJames Foster
andauthored
Report error when reading file list. (#424)
Co-authored-by: James Foster <git@jgfoster.net>
1 parent 2b0c0df commit b03697b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

extras/web_client/lib/model/app_data.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,22 @@ class AppData with ChangeNotifier {
6868
Future<void> refreshFiles() async {
6969
if (currentTank.isEmpty()) {
7070
_files = jsonDecode('{"Error: Choose tank from menu":""}');
71-
} else {
72-
var tcInterface = TcInterface.instance();
73-
// wait 15 seconds (the default of 5 seconds could be too little)
74-
var value = await tcInterface.get(currentTank.ip, 'rootdir', 15);
71+
return;
72+
}
73+
var tcInterface = TcInterface.instance();
74+
var value = '';
75+
// wait 15 seconds (the default of 5 seconds could be too little)
76+
try {
77+
value = await tcInterface.get(currentTank.ip, 'rootdir', 15);
7578
while (value.substring(value.length - 1) == '\n') {
7679
value = value.substring(0, value.length - 1);
7780
}
7881
value = value.replaceAll('\n', '", "');
7982
value = value.replaceAll('\t', '":"');
8083
value = '{"$value"}';
8184
_files = jsonDecode(value);
85+
} catch (e) {
86+
_files = jsonDecode('{"Error: $e":""}');
8287
}
8388
notifyListeners();
8489
}

0 commit comments

Comments
 (0)