summaryrefslogtreecommitdiff
path: root/lib/_debugger.js
diff options
context:
space:
mode:
authorJackson Tian <puling.tyq@alibaba-inc.com>2015-06-01 22:12:25 +0800
committerBen Noordhuis <info@bnoordhuis.nl>2015-06-05 05:54:19 +0200
commit81029c639ad5aa566d9ff25d31f73ef279ad2b8d (patch)
treeef5e22133e57893ddf8605ef23eb66a009a6a3e1 /lib/_debugger.js
parent353e26e3c7ed9d160028ea7517d05edbebab5e7d (diff)
downloadnodejs-81029c639ad5aa566d9ff25d31f73ef279ad2b8d.tar.gz
nodejs-81029c639ad5aa566d9ff25d31f73ef279ad2b8d.tar.bz2
nodejs-81029c639ad5aa566d9ff25d31f73ef279ad2b8d.zip
debugger: improve ESRCH error message
When using `iojs debug -p <pid>` with an invalid pid, the debugger printed an internal error message because it wasn't smart enough to figure out that the target process didn't exist. Now it is. PR-URL: https://github.com/nodejs/io.js/pull/1863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Diffstat (limited to 'lib/_debugger.js')
-rw-r--r--lib/_debugger.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/_debugger.js b/lib/_debugger.js
index 4c503d2f5..83086ffb5 100644
--- a/lib/_debugger.js
+++ b/lib/_debugger.js
@@ -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+)$/);
@@ -1704,8 +1713,8 @@ Interface.prototype.trySpawn = function(cb) {
function connectError() {
// If it's failed to connect 10 times then print failed message
if (connectionAttempts >= 10) {
- self.stdout.write(' failed, please retry\n');
- return;
+ console.error(' failed, please retry');
+ process.exit(1);
}
setTimeout(attemptConnect, 500);
}