From 29b7a7181266370ea6601e5089982712065275d2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 7 Nov 2013 09:05:44 -0800 Subject: [PATCH] Ensure there is a `response` object before accessing its `statusCode`. --- test/saucelabs.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/saucelabs.js b/test/saucelabs.js index d31739eee..be2336c86 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -146,10 +146,14 @@ 'auth': { 'user': username, 'pass': accessKey }, 'json': testDefinition }, function(error, response, body) { - if (response.statusCode == 200) { + var statusCode = response && response.statusCode; + if (statusCode == 200) { waitForTestCompletion(body); } else { - console.error('Failed to submit test to Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body)); + console.error('Failed to submit test to Sauce Labs; status: ' + statusCode + ', body:\n' + JSON.stringify(body)); + if (error) { + console.error(error); + } process.exit(3); } }); @@ -160,7 +164,8 @@ 'auth': { 'user': username, 'pass': accessKey }, 'json': testIdentifier }, function(error, response, body) { - if (response.statusCode == 200) { + var statusCode = response && response.statusCode; + if (statusCode == 200) { if (body.completed) { logInline(''); handleTestResults(body['js tests']); @@ -173,7 +178,10 @@ } } else { logInline(''); - console.error('Failed to check test status on Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body)); + console.error('Failed to check test status on Sauce Labs; status: ' + statusCode + ', body:\n' + JSON.stringify(body)); + if (error) { + console.error(error); + } process.exit(4); } });