@@ -847,11 +847,23 @@ void NativeScriptRuntime::RequireCallback(const v8::FunctionCallbackInfo<v8::Val
847847{
848848 SET_PROFILER_FRAME ();
849849
850- ASSERT_MESSAGE (args.Length () == 2 , " require should be called with two parameters" );
851- ASSERT_MESSAGE (!args[0 ]->IsUndefined () && !args[0 ]->IsNull (), " require called with undefined moduleName parameter" );
852- ASSERT_MESSAGE (!args[1 ]->IsUndefined () && !args[1 ]->IsNull (), " require called with undefined callingModulePath parameter" );
853- ASSERT_MESSAGE (args[0 ]->IsString (), " require should be called with string parameter" );
854- ASSERT_MESSAGE (args[1 ]->IsString (), " require should be called with string parameter" );
850+ auto isolate = Isolate::GetCurrent ();
851+
852+ if (args.Length () != 2 )
853+ {
854+ isolate->ThrowException (ConvertToV8String (" require should be called with two parameters" ));
855+ return ;
856+ }
857+ if (!args[0 ]->IsString ())
858+ {
859+ isolate->ThrowException (ConvertToV8String (" require's first parameter should be string" ));
860+ return ;
861+ }
862+ if (!args[1 ]->IsString ())
863+ {
864+ isolate->ThrowException (ConvertToV8String (" require's second parameter should be string" ));
865+ return ;
866+ }
855867
856868 string moduleName = ConvertToString (args[0 ].As <String>());
857869 string callingModuleDirName = ConvertToString (args[1 ].As <String>());
@@ -861,8 +873,6 @@ void NativeScriptRuntime::RequireCallback(const v8::FunctionCallbackInfo<v8::Val
861873 JniLocalRef jsCallingModuleDirName (env.NewStringUTF (callingModuleDirName.c_str ()));
862874 JniLocalRef jsModulePath (env.CallStaticObjectMethod (RequireClass, GET_MODULE_PATH_METHOD_ID, (jstring) jsModulename, (jstring) jsCallingModuleDirName));
863875
864- auto isolate = Isolate::GetCurrent ();
865-
866876 // cache the required modules by full path, not name only, since there might be some collisions with relative paths and names
867877 string modulePath = ArgConverter::jstringToString ((jstring) jsModulePath);
868878 if (modulePath == " " ){
0 commit comments