Skip to content

Commit fa1fdb5

Browse files
author
Mihail Slavchev
committed
replace ASSERT_MESSAGE with V8 exception (issue #221)
1 parent 04293aa commit fa1fdb5

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/jni/MetadataNode.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,21 +737,34 @@ void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v
737737
ASSERT_FAIL("Invalid extend() call. No name specified for extend. Location: %s", extendLocation.c_str());
738738
}
739739

740-
ASSERT_MESSAGE(info[0]->IsObject(), "Invalid extend() call. No implementation object specified. Location: %s", extendLocation.c_str());
740+
if (!info[0]->IsObject())
741+
{
742+
isolate->ThrowException(ConvertToV8String("First argument must be implementation object"));
743+
return;
744+
}
741745
implementationObject = info[0]->ToObject();
742746
}
743747
else if (info.Length() == 2)
744748
{
745-
ASSERT_MESSAGE(info[0]->IsString(), "Invalid extend() call. No name for extend specified. Location: %s", extendLocation.c_str());
746-
ASSERT_MESSAGE(info[1]->IsObject(), "Invalid extend() call. Named extend should be called with second object parameter containing overridden methods. Location: %s", extendLocation.c_str());
749+
if (!info[0]->IsString())
750+
{
751+
isolate->ThrowException(ConvertToV8String("First argument must be string"));
752+
return;
753+
}
754+
if (!info[1]->IsObject())
755+
{
756+
isolate->ThrowException(ConvertToV8String("Second argument must be implementation object"));
757+
return;
758+
}
747759

748760
DEBUG_WRITE("InterfaceConstructorCallback: getting extend name");
749761
v8ExtendName = info[0]->ToString();
750762
implementationObject = info[1]->ToObject();
751763
}
752764
else
753765
{
754-
ASSERT_FAIL("Invalid extend() call. Location: %s", extendLocation.c_str());
766+
isolate->ThrowException(ConvertToV8String("Invalid number of arguments"));
767+
return;
755768
}
756769

757770
auto className = node->m_implType;

0 commit comments

Comments
 (0)