[gjs] coverage: Return undefined instead of throwing



commit 9ae78c152a085d5aae4ae43ee4f82e2d8c0675fb
Author: Sam Spilsbury <smspillaz gmail com>
Date:   Thu Jul 2 12:32:29 2015 +0800

    coverage: Return undefined instead of throwing
    
    When coverage statistics aren't requested for a file, just
    return undefined instead of throwing. For legitimately
    exceptional cases, we should catch the error and report
    it, instead of just swallowing all errors as a normal
    "bail out" case.

 modules/coverage.js |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/modules/coverage.js b/modules/coverage.js
index 0ae96f7..9dcd962 100644
--- a/modules/coverage.js
+++ b/modules/coverage.js
@@ -774,11 +774,7 @@ function CoverageStatisticsContainer(prefixes, cache) {
     };
 
     this.fetchStatistics = function(filename) {
-        let statistics = ensureStatisticsFor(filename);
-
-        if (statistics === undefined)
-            throw new Error('Not tracking statistics for ' + filename);
-        return statistics;
+        return ensureStatisticsFor(filename);
     };
 
     this.staleCache = function() {
@@ -830,8 +826,12 @@ function CoverageStatistics(prefixes, cache) {
 
         try {
             statistics = fetchStatistics(frame.script.url);
+            if (!statistics) {
+                return undefined;
+            }
         } catch (e) {
             /* We don't care about this frame, return */
+            warning(e.message + " " + e.stack);
             return undefined;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]