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 2, 2015
1 parent c0e7bf2 commit bf9bffa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions 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));
const pid = parseInt(this.args[2], 10);
try {
process._debugProcess(pid);
} catch (e) {
if (e.code === 'ESRCH') {
console.error('Target process: ' + pid + ' doesn\'t exist.');
process.exit(1);
}
throw e;
}
isRemote = true;
} else {
var match = this.args[1].match(/^--port=(\d+)$/);
Expand Down Expand Up @@ -1705,7 +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');
return;
process.exit(1);
}
setTimeout(attemptConnect, 500);
}
Expand Down

0 comments on commit bf9bffa

Please sign in to comment.