Skip to content

Commit

Permalink
debugger: improve ESRCH error message
Browse files Browse the repository at this point in the history
When use `iojs debug -p <pid>` with an invalid pid,
the debugger print internal error message also,
it not enough smart.
  • Loading branch information
JacksonTian committed Jun 1, 2015
1 parent c0e7bf2 commit 58827e7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,16 @@ Interface.prototype.trySpawn = function(cb) {
} else if (this.args.length === 3) {
// `node debug -p pid`
if (this.args[1] === '-p' && /^\d+$/.test(this.args[2])) {
process._debugProcess(parseInt(this.args[2], 10));
var pid = parseInt(this.args[2], 10);
try {
process._debugProcess(pid);
} catch (e) {
if (e.code === 'ESRCH') {
console.error('Target process: ' + pid + ' doesn\'t exists.');
process.exit(1);
}
throw e;
}
isRemote = true;
} else {
var match = this.args[1].match(/^--port=(\d+)$/);
Expand Down Expand Up @@ -1705,6 +1714,7 @@ Interface.prototype.trySpawn = function(cb) {
// If it's failed to connect 10 times then print failed message
if (connectionAttempts >= 10) {
self.stdout.write(' failed, please retry\n');
process.exit(1);
return;
}
setTimeout(attemptConnect, 500);
Expand Down

0 comments on commit 58827e7

Please sign in to comment.