Browse Source

Wrap NewInstance with TryCatch. (Was still missing the error.)

v0.7.4-release
Ryan 16 years ago
parent
commit
589d8af5d4
  1. 7
      src/http.cc
  2. 3
      src/http.js
  3. 8
      src/net.cc
  4. 10
      src/node.cc

7
src/http.cc

@ -334,9 +334,16 @@ HTTPServer::OnConnection (struct sockaddr *addr, socklen_t len)
return NULL;
}
TryCatch try_catch;
Local<Object> connection_handle =
HTTPConnection::server_constructor_template->GetFunction()->NewInstance(0, NULL);
if (connection_handle.IsEmpty()) {
fatal_exception(try_catch);
return NULL;
}
HTTPConnection *connection = NODE_UNWRAP(HTTPConnection, connection_handle);
if (!connection) return NULL;

3
src/http.js

@ -210,7 +210,8 @@ node.http.Server = function (RequestHandler, options) {
this.onBodyComplete = function () { return true; }
}
this.onMessage = function ( ) {
connection.onMessage = function ( ) {
puts("got onMessage");
var msg = new Message();
msg.path = "";

8
src/net.cc

@ -409,8 +409,15 @@ Acceptor::OnConnection (struct sockaddr *addr, socklen_t len)
return NULL;
}
TryCatch try_catch;
Local<Object> connection_handle =
Connection::constructor_template->GetFunction()->NewInstance(0, NULL);
if (connection_handle.IsEmpty()) {
fatal_exception(try_catch);
return NULL;
}
Connection *connection = NODE_UNWRAP(Connection, connection_handle);
if (!connection) return NULL;
@ -419,7 +426,6 @@ Acceptor::OnConnection (struct sockaddr *addr, socklen_t len)
Handle<Value> argv[1] = { connection_handle };
TryCatch try_catch;
Local<Value> ret = connection_handler->Call(handle_, 1, argv);
if (ret.IsEmpty())

10
src/node.cc

@ -61,13 +61,17 @@ void*
ObjectWrap::Unwrap (Handle<Object> handle)
{
HandleScope scope;
if(handle.IsEmpty() || handle->InternalFieldCount() == 0) {
ThrowException(String::New("Tried to unwrap object without internal field."));
if (handle.IsEmpty()) {
fprintf(stderr, "Node: Tried to unwrap empty object.\n");
return NULL;
}
if ( handle->InternalFieldCount() == 0) {
fprintf(stderr, "Node: Tried to unwrap object without internal fields.\n");
return NULL;
}
Local<Value> value = handle->GetInternalField(0);
if (value.IsEmpty()) {
ThrowException(String::New("Tried to unwrap object with empty internal field."));
fprintf(stderr, "Tried to unwrap object with empty internal field.\n");
return NULL;
}
Handle<External> field = Handle<External>::Cast(value);

Loading…
Cancel
Save