throw error when given a bad arguement to socket.write
authorRyan <ry@tinyclouds.org>
Wed, 22 Apr 2009 12:01:06 +0000 (14:01 +0200)
committerRyan <ry@tinyclouds.org>
Wed, 22 Apr 2009 12:01:45 +0000 (14:01 +0200)
src/net.cc

index 16885ef..81bba00 100644 (file)
@@ -423,6 +423,8 @@ Socket::Write (const Arguments& args)
   HandleScope scope;
 
   Socket *socket = Socket::Unwrap(args.Holder());
+
+  // TODO support a callback using buf->on_release
  
   if (args[0] == Null()) {
     oi_socket_write_eof(&socket->socket_);
@@ -446,10 +448,8 @@ Socket::Write (const Arguments& args)
     }
     oi_socket_write(&socket->socket_, buf);
 
-  } else {
-    // raise error bad argument.
-    assert(0);
-  }
+  } else return ThrowException(String::New("Bad argument"));
+  
 
   return Undefined();
 }