danwrong / restler

REST client library for node.js
MIT License
1.99k stars 391 forks source link

.on('complete') callback returning non-Error object on ECONNREFUSED #181

Open celesteking opened 10 years ago

celesteking commented 10 years ago

When connection is refused and no error handlers are attached, returned object in "complete" CB is not of Error type.

.on('complete', function(data, response){
if (data instanceof Error) {
  // blah
} else {
  //  gets here instead of there
}

The data object itself:

 { [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }

Thanks.