Skip to content

Commit

Permalink
add more error handling in instruments_client
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Nov 12, 2013
1 parent 3ae42fe commit f8897c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bin/instruments-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/devices/ios/uiauto/lib/instruments_client_launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit f8897c0

Please sign in to comment.