Browse Source

Catch the JSON undefined error

Gaël Métais 10 years ago
parent
commit
58b9a44554
1 changed files with 6 additions and 5 deletions
  1. 6 5
      app/lib/phantomasWrapper.js

+ 6 - 5
app/lib/phantomasWrapper.js

@@ -81,17 +81,18 @@ var PhantomasWrapper = function() {
                     err = 1001;
                     err = 1001;
                 }
                 }
 
 
+                if (!json || !json.metrics) {
+                    console.log('IIIIIIIIIIK');
+                    console.log(err);
+                    console.log(json);
+                }
+
                 // Don't cancel test if it is a timeout and we've got some results
                 // Don't cancel test if it is a timeout and we've got some results
                 if (err === 252 && json) {
                 if (err === 252 && json) {
                     console.log('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
                     console.log('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
                     err = null;
                     err = null;
                 }
                 }
 
 
-                // Strange bug: no err but no json either
-                /*if (!json && json == 'undefined') {
-                    err = 1002;
-                }*/
-
                 if (err) {
                 if (err) {
                     console.log('Attempt failed for test id ' + task.testId + '. Error code ' + err);
                     console.log('Attempt failed for test id ' + task.testId + '. Error code ' + err);
                 }
                 }