Skip to content

Commit a9b1610

Browse files
committed
fix: enhance error handling in LoadESModule by throwing NativeScriptException on promise rejection
1 parent dc46a79 commit a9b1610

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

NativeScript/runtime/ModuleInternal.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,13 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
885885
if (state == Promise::kRejected) {
886886
RemoveModuleFromRegistry(canonicalPath);
887887
logPhase("evaluate", "promise-rejected");
888-
if (!promiseTc.HasCaught()) {
888+
if (promiseTc.HasCaught()) {
889+
throw NativeScriptException(isolate, promiseTc, "Module evaluation promise rejected");
890+
} else {
889891
Local<Value> reason = promise->Result();
890892
isolate->ThrowException(reason);
893+
throw NativeScriptException(isolate, "Module evaluation promise rejected");
891894
}
892-
throw NativeScriptException(isolate, promiseTc, "Module evaluation promise rejected");
893895
}
894896
if (IsScriptLoadingLogEnabled()) {
895897
Log("LoadESModule: Promise resolved successfully\n");

0 commit comments

Comments
 (0)