Skip to content

Commit 5033ebd

Browse files
committed
Syntax error should be visible correctly
1 parent 6637a7c commit 5033ebd

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Plugins/UnrealJS/Source/V8/Private/Exception.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct FV8Exception
2020
auto linenum = message->GetLineNumber();
2121
auto line = StringFromV8(message->GetSourceLine());
2222

23+
UE_LOG(Javascript, Error, TEXT("%s:%d: %s"), *filename, linenum, *exception);
24+
2325
auto stack_trace = StringFromV8(try_catch.StackTrace());
2426
if (stack_trace.Len() > 0)
2527
{

Plugins/UnrealJS/Source/V8/Private/JavascriptContext_Private.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,16 +1427,23 @@ class FJavascriptContextImplementation : public FJavascriptContext
14271427
auto path = V8_String(isolate(), Path);
14281428
ScriptOrigin origin(path, Integer::New(isolate(), -line_offset));
14291429
auto script = Script::Compile(source, &origin);
1430-
1431-
auto result = script->Run();
1432-
if (try_catch.HasCaught())
1430+
if (script.IsEmpty())
14331431
{
14341432
FV8Exception::Report(try_catch);
14351433
return Local<Value>();
14361434
}
14371435
else
14381436
{
1439-
return result;
1437+
auto result = script->Run();
1438+
if (try_catch.HasCaught())
1439+
{
1440+
FV8Exception::Report(try_catch);
1441+
return Local<Value>();
1442+
}
1443+
else
1444+
{
1445+
return result;
1446+
}
14401447
}
14411448
}
14421449

0 commit comments

Comments
 (0)