#include <v8.h>#include <node.h>inline Local<Value> ThrowTypeError(const char* message) {HandleScope scope;ThrowException(Exception::TypeError(String::New(message)));return scope.Close(Undefined());};Handle<Value> SomeMethod(const Arguments &args) {HandleScope scope:if (!args[0]->IsObject() || args[0]->IsArray())return ThrowTypeError("Argument must be a object literal.");return scope.Close(args[0]->ToObject());};NODE_MODULE(test, init);
Hello,I want to use a function which acts as internal exception shortcut unfortunately I cannot pass the current scope so I would create a new one.Is this whole strategy valid? If not how would it look right?
Handle<Value> SomeMethod(const Arguments &args) {
HandleScope scope:if (!args[0]->IsObject() || args[0]->IsArray())
return ThrowTypeError("Argument must be a object literal.");return scope.Close(args[0]->ToObject());};NODE_MODULE(test, init);
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/Q5D2lsbYb1M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I require scope.Close() to return a value
. My sorrow is that I could get problems with GC because I did not close the scope or something.But you do not confirm these sorrows?
To the second:Yes that is why there is args[0]->IsArray()
I think you oversaw the "!" (so "!obj->IsObject()).
OR will stop on the first "true" else it will go through each expression. !obj->IsObject() will so filter the primitive values else I agree :)