Skip to content

Commit bd94320

Browse files
committed
check for construct calls to avoid assertion failures
fixes kkaefer#2
1 parent 1331990 commit bd94320

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

06_objects/modulename.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ MyObject::MyObject(int val)
3434
Handle<Value> MyObject::New(const Arguments& args) {
3535
HandleScope scope;
3636

37+
if (!args.IsConstructCall()) {
38+
return ThrowException(Exception::TypeError(
39+
String::New("Use the new operator to create instances of this object."))
40+
);
41+
}
42+
3743
if (args.Length() < 1) {
3844
return ThrowException(Exception::TypeError(
3945
String::New("First argument must be a number")));

0 commit comments

Comments
 (0)