Преглед изворни кода

Gallery: log failures in loadFiles method

Neeraj Gupta пре 3 година
родитељ
комит
c7da836656
1 измењених фајлова са 23 додато и 12 уклоњено
  1. 23 12
      lib/ui/gallery.dart

+ 23 - 12
lib/ui/gallery.dart

@@ -100,18 +100,29 @@ class _GalleryState extends State<Gallery> {
 
   Future<FileLoadResult> _loadFiles({int limit}) async {
     _logger.info("Loading files");
-    final startTime = DateTime.now().microsecondsSinceEpoch;
-    final result = await widget.asyncLoader(
-        kGalleryLoadStartTime, DateTime.now().microsecondsSinceEpoch,
-        limit: limit);
-    final endTime = DateTime.now().microsecondsSinceEpoch;
-    final duration = Duration(microseconds: endTime - startTime);
-    _logger.info("Time taken to load " +
-        result.files.length.toString() +
-        " files :" +
-        duration.inMilliseconds.toString() +
-        "ms");
-    return result;
+    try {
+      final startTime = DateTime
+          .now()
+          .microsecondsSinceEpoch;
+      final result = await widget.asyncLoader(
+          kGalleryLoadStartTime, DateTime
+          .now()
+          .microsecondsSinceEpoch,
+          limit: limit);
+      final endTime = DateTime
+          .now()
+          .microsecondsSinceEpoch;
+      final duration = Duration(microseconds: endTime - startTime);
+      _logger.info("Time taken to load " +
+          result.files.length.toString() +
+          " files :" +
+          duration.inMilliseconds.toString() +
+          "ms");
+      return result;
+    } catch(e, s) {
+      _logger.severe("failed to load files", e, s);
+      rethrow;
+    }
   }
 
   // Collates files and returns `true` if it resulted in a gallery reload