Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Expose errno with a string.
  • Loading branch information
ry committed Feb 4, 2011
1 parent 1a7830a commit aa95e57
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/net.markdown
Expand Up @@ -70,7 +70,7 @@ another server is already running on the requested port. One way of handling thi
would be to wait a second and the try again. This can be done with

server.on('error', function (e) {
if (e.errno == require('constants').EADDRINUSE) {
if (e.code == 'EADDRINUSE') {
console.log('Address in use, retrying...');
setTimeout(function () {
server.close();
Expand Down
3 changes: 3 additions & 0 deletions src/node.cc
Expand Up @@ -71,6 +71,7 @@ static Persistent<Object> process;
static Persistent<String> errno_symbol;
static Persistent<String> syscall_symbol;
static Persistent<String> errpath_symbol;
static Persistent<String> code_symbol;

static Persistent<String> rss_symbol;
static Persistent<String> vsize_symbol;
Expand Down Expand Up @@ -1021,6 +1022,7 @@ Local<Value> ErrnoException(int errorno,
syscall_symbol = NODE_PSYMBOL("syscall");
errno_symbol = NODE_PSYMBOL("errno");
errpath_symbol = NODE_PSYMBOL("path");
code_symbol = NODE_PSYMBOL("code");
}

if (path) {
Expand All @@ -1035,6 +1037,7 @@ Local<Value> ErrnoException(int errorno,
Local<Object> obj = e->ToObject();

obj->Set(errno_symbol, Integer::New(errorno));
obj->Set(code_symbol, estring);
if (path) obj->Set(errpath_symbol, String::New(path));
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
return e;
Expand Down
1 change: 1 addition & 0 deletions test/simple/test-net-connect-handle-econnrefused.js
Expand Up @@ -16,6 +16,7 @@ c.on('error', function(e) {
console.error('couldn\'t connect.');
gotError = true;
assert.equal(require('constants').ECONNREFUSED, e.errno);
assert.equal('ECONNREFUSED', e.code);
});


Expand Down

0 comments on commit aa95e57

Please sign in to comment.