pkrumins / node-tree-kill

kill trees of processes
MIT License
335 stars 37 forks source link

More friendly error message when `ps` is not available #29

Open OJezu opened 4 years ago

OJezu commented 4 years ago

If no ps program is available on Linux, this package throws a generic ENOENT error. When this library is a dependency of dependency, its not immediately clear where from exactly the error is coming. For ease of debugging, maybe a custom error should be thrown, with message like "tree-kill package needs ps command to be available in PATH" or similar.

events.js:186
      throw er; // Unhandled 'error' event
      ^

Error: spawn ps ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn ps',
  path: 'ps',
  spawnargs: [ '-o', 'pid', '--no-headers', '--ppid', 185 ]
}

see nestjs/nest-cli#484