Skip to content

Commit dafe63c

Browse files
committed
runtime: throw exception if module eval fails
1 parent 480fd18 commit dafe63c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

test-app/runtime/src/main/cpp/runtime/Runtime.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,13 @@ void Runtime::RunModule(JNIEnv *_jEnv, jobject obj, jstring scriptFile) {
445445
JEnv jEnv(_jEnv);
446446
string filePath = ArgConverter::jstringToString(scriptFile);
447447
m_module.Load(env, filePath);
448+
bool pendingException;
449+
napi_is_exception_pending(env, &pendingException);
450+
if (pendingException) {
451+
napi_value error = nullptr;
452+
napi_get_and_clear_last_exception(env, &error);
453+
throw NativeScriptException(env, error, string("Error running module at path: ") + filePath);
454+
}
448455
}
449456

450457
void Runtime::RunModule(const char *moduleName) {

0 commit comments

Comments
 (0)