Wrap NewInstance with TryCatch. (Was still missing the error.)
authorRyan <ry@tinyclouds.org>
Thu, 14 May 2009 23:36:51 +0000 (01:36 +0200)
committerRyan <ry@tinyclouds.org>
Thu, 14 May 2009 23:36:51 +0000 (01:36 +0200)
src/http.cc
src/http.js
src/net.cc
src/node.cc

index fda19fe..2eb9ab4 100644 (file)
@@ -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;
 
index c1f0aa7..ad091d6 100644 (file)
@@ -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 = "";
index 40bafad..515bb64 100644 (file)
@@ -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())
index 277717b..e9254ed 100644 (file)
@@ -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);