From f8897c00cd161fad3155101f82a5b86fa744a12b Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Tue, 12 Nov 2013 12:15:52 -0800 Subject: [PATCH] add more error handling in instruments_client --- bin/instruments-client.js | 17 +++++++++++++++-- .../uiauto/lib/instruments_client_launcher.js | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/instruments-client.js b/bin/instruments-client.js index cf50900ba6a..b6d6d364061 100755 --- a/bin/instruments-client.js +++ b/bin/instruments-client.js @@ -8,13 +8,26 @@ var connect = function(args) { var client = net.connect({path: args.socket}, function() { var data = {event: "cmd"}; if (args.result) { - data.result = JSON.parse(args.result); + process.stderr.write("Sending result to server: " + args.result); + try { + data.result = JSON.parse(args.result); + } catch (e) { + process.stderr.write(e.message); + throw e; + } } + process.stderr.write("Sending response to server"); data = JSON.stringify(data); client.end(data, "utf8"); }); client.on('data', function(data) { - data = JSON.parse(data); + try { + data = JSON.parse(data); + } catch (e) { + process.stderr.write(e.message); + throw e; + } + process.stderr.write("Received response from server: " + JSON.stringify(data)); process.stdout.write(data.nextCommand); client.end(); process.exit(0); diff --git a/lib/devices/ios/uiauto/lib/instruments_client_launcher.js b/lib/devices/ios/uiauto/lib/instruments_client_launcher.js index 8d93b527e0e..e7ea00e3ea0 100644 --- a/lib/devices/ios/uiauto/lib/instruments_client_launcher.js +++ b/lib/devices/ios/uiauto/lib/instruments_client_launcher.js @@ -217,6 +217,7 @@ var sendResultAndGetNext = function(result) { console.log(res.stderr); console.log("And stdout:"); console.log(res.stdout); + return null; } return res.stdout; };