Handle initial connection errors

Issue #1 resolved
Trippnology repo owner created an issue

If you try to run js8-cli and JS8Call is not open, the port is in use, or you set an invalid port, the app crashes with:

$> js8-cli -h
events.js:200
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:2442
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 2442
}

We should be catching this error and responding with a friendly message, such as:

Could not establish a connection to JS8Call. Maybe JS8Call is not running, or the port is in use by another program.

Comments (1)

  1. Log in to comment