Skip to content

Instantly share code, notes, and snippets.

@bodokaiser
Last active December 16, 2015 05:18
Show Gist options
  • Save bodokaiser/5383105 to your computer and use it in GitHub Desktop.
Save bodokaiser/5383105 to your computer and use it in GitHub Desktop.
#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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment