Expose errno exception creation
This commit is contained in:
Родитель
979f5889d5
Коммит
b6edae5671
|
@ -27,6 +27,7 @@ var socketError = process.socketError;
|
|||
var getsockname = process.getsockname;
|
||||
var getaddrinfo = process.getaddrinfo;
|
||||
var needsLookup = process.needsLookup;
|
||||
var errnoException = process.errnoException;
|
||||
var EINPROGRESS = process.EINPROGRESS;
|
||||
var ENOENT = process.ENOENT;
|
||||
var END_OF_FILE = 0;
|
||||
|
@ -397,7 +398,7 @@ Socket.prototype.connect = function () {
|
|||
self._writeWatcher.set(self.fd, false, true);
|
||||
self._writeWatcher.start();
|
||||
self._writeWatcher.callback = function () {
|
||||
var errno = socketError(self.fd);
|
||||
var errno = socketError(self.fd);
|
||||
if (errno == 0) {
|
||||
// connection established
|
||||
self._readWatcher.start();
|
||||
|
@ -406,9 +407,7 @@ Socket.prototype.connect = function () {
|
|||
self._writeWatcher.callback = self._doFlush;
|
||||
self.emit('connect');
|
||||
} else if (errno != EINPROGRESS) {
|
||||
var e = new Error('connection error');
|
||||
e.errno = errno;
|
||||
self.forceClose(e);
|
||||
self.forceClose(errnoException(errno, 'connect'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1246,6 +1246,18 @@ static Handle<Value> NeedsLookup(const Arguments& args) {
|
|||
}
|
||||
|
||||
|
||||
static Handle<Value> CreateErrnoException(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
int errorno = args[0]->Int32Value();
|
||||
String::Utf8Value syscall(args[1]->ToString());
|
||||
|
||||
Local<Value> exception = ErrnoException(errorno, *syscall);
|
||||
|
||||
return scope.Close(exception);
|
||||
}
|
||||
|
||||
|
||||
void InitNet2(Handle<Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
|
@ -1275,6 +1287,7 @@ void InitNet2(Handle<Object> target) {
|
|||
NODE_SET_METHOD(target, "getpeername", GetPeerName);
|
||||
NODE_SET_METHOD(target, "getaddrinfo", GetAddrInfo);
|
||||
NODE_SET_METHOD(target, "needsLookup", NeedsLookup);
|
||||
NODE_SET_METHOD(target, "errnoException", CreateErrnoException);
|
||||
|
||||
target->Set(String::NewSymbol("ENOENT"), Integer::New(ENOENT));
|
||||
target->Set(String::NewSymbol("EINPROGRESS"), Integer::New(EINPROGRESS));
|
||||
|
|
Загрузка…
Ссылка в новой задаче