@@ -763,21 +763,11 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
763763 }
764764 logPhase (" compile" , " fail" , classification);
765765 // V8 threw a syntax error or similar
766- if (RuntimeConfig.IsDebug ) {
767- // Log the detailed JavaScript error with full stack trace
768- Log (@" ***** JavaScript exception occurred *****" );
766+ if (RuntimeConfig.IsDebug && tcCompile.HasCaught ()) {
769767 Log (@" Error compiling ES module: %s " , canonicalPath.c_str ());
770- if (tcCompile.HasCaught ()) {
771- tns::LogError (isolate, tcCompile);
772- }
773- Log (@" ***** Debug mode - continuing execution *****" );
774- Log (@" ES module compilation failed: %s " , canonicalPath.c_str ());
775- // Return empty to prevent crashes
776- return Local<Value>();
777- } else {
778- throw NativeScriptException (isolate, tcCompile,
779- " Cannot compile ES module " + canonicalPath);
768+ tns::LogError (isolate, tcCompile);
780769 }
770+ throw NativeScriptException (isolate, tcCompile, " Cannot compile ES module " + canonicalPath);
781771 }
782772 }
783773 logPhase (" compile" , " ok" );
@@ -826,24 +816,14 @@ throw NativeScriptException(isolate, tcCompile,
826816 }
827817 }
828818 logPhase (" instantiate" , " fail" , classification);
829- if (RuntimeConfig.IsDebug ) {
830- // Log the detailed JavaScript error with full stack trace
831- Log (@" ***** JavaScript exception occurred *****" );
819+ if (RuntimeConfig.IsDebug && tcLink.HasCaught ()) {
832820 Log (@" Error instantiating module: %s " , canonicalPath.c_str ());
833- if (tcLink.HasCaught ()) {
834- tns::LogError (isolate, tcLink);
835- }
836- Log (@" ***** Debug mode - continuing execution *****" );
837- Log (@" Module instantiation failed: %s " , canonicalPath.c_str ());
838- return Local<Value>();
821+ tns::LogError (isolate, tcLink);
822+ }
823+ if (tcLink.HasCaught ()) {
824+ throw NativeScriptException (isolate, tcLink, " Cannot instantiate module " + canonicalPath);
839825 } else {
840- if (tcLink.HasCaught ()) {
841- throw NativeScriptException (isolate, tcLink,
842- " Cannot instantiate module " + canonicalPath);
843- } else {
844- // V8 gave no exception object—throw plain text
845- throw NativeScriptException (isolate, " Cannot instantiate module " + canonicalPath);
846- }
826+ throw NativeScriptException (isolate, " Cannot instantiate module " + canonicalPath);
847827 }
848828 }
849829 }
@@ -874,19 +854,11 @@ throw NativeScriptException(isolate, tcLink,
874854 }
875855 }
876856 logPhase (" evaluate" , " fail" , classification);
877- if (RuntimeConfig.IsDebug ) {
878- // Log the detailed JavaScript error with full stack trace
879- Log (@" ***** JavaScript exception occurred *****" );
857+ if (RuntimeConfig.IsDebug && tcEval.HasCaught ()) {
880858 Log (@" Error evaluating ES module: %s " , canonicalPath.c_str ());
881- if (tcEval.HasCaught ()) {
882- tns::LogError (isolate, tcEval);
883- }
884- Log (@" ***** Debug mode - continuing execution *****" );
885- Log (@" Module evaluation failed: %s " , canonicalPath.c_str ());
886- return Local<Value>();
887- } else {
888- throw NativeScriptException (isolate, tcEval, " Cannot evaluate module " + canonicalPath);
859+ tns::LogError (isolate, tcEval);
889860 }
861+ throw NativeScriptException (isolate, tcEval, " Cannot evaluate module " + canonicalPath);
890862 }
891863 logPhase (" evaluate" , " ok" );
892864
0 commit comments