Skip to content

Commit f7133de

Browse files
committed
fix: rethrow NativeScriptException in LoadESModule for better error handling
1 parent 0dd7c77 commit f7133de

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

NativeScript/runtime/ModuleInternal.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ bool IsESModule(const std::string& path) {
168168
Local<Value> moduleNamespace;
169169
try {
170170
moduleNamespace = ModuleInternal::LoadESModule(isolate, path);
171-
} catch (const NativeScriptException& ex) {
171+
} catch (NativeScriptException& ex) {
172172
if (RuntimeConfig.IsDebug) {
173173
Log(@"Error loading ES module: %s", path.c_str());
174174
Log(@"Exception: %s", ex.getMessage().c_str());
175175
}
176+
ex.ReThrowToV8(isolate);
176177
return false;
177178
}
178179
return true;
@@ -202,6 +203,9 @@ bool IsESModule(const std::string& path) {
202203
tns::LogError(isolate, tc);
203204
}
204205
}
206+
if (tc.HasCaught()) {
207+
tc.ReThrow();
208+
}
205209
return false;
206210
}
207211

0 commit comments

Comments
 (0)