Skip to content

Commit

Permalink
check for construct calls to avoid assertion failures
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
kkaefer committed Dec 8, 2011
1 parent 1331990 commit bd94320
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions 06_objects/modulename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ MyObject::MyObject(int val)
Handle<Value> MyObject::New(const Arguments& args) {
HandleScope scope;

if (!args.IsConstructCall()) {
return ThrowException(Exception::TypeError(
String::New("Use the new operator to create instances of this object."))
);
}

if (args.Length() < 1) {
return ThrowException(Exception::TypeError(
String::New("First argument must be a number")));
Expand Down

0 comments on commit bd94320

Please sign in to comment.