Skip to content

Commit 5bcca5b

Browse files
authored
Fix exception handlers for tests (#1588)
1 parent 93e3524 commit 5bcca5b

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

Apps/UnitTests/Source/Tests.JavaScript.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ TEST(JavaScript, All)
4545
Babylon::AppRuntime::Options options{};
4646

4747
options.UnhandledExceptionHandler = [&exitCodePromise](const Napi::Error& error) {
48-
std::cerr << "[Uncaught Error] " << error.Get("stack").As<Napi::String>().Utf8Value() << std::endl;
48+
std::cerr << "[Uncaught Error] " << Napi::GetErrorString(error) << std::endl;
4949
std::cerr.flush();
5050

51-
exitCodePromise.set_value(-1);
51+
exitCodePromise.set_exception(std::make_exception_ptr(std::exception{}));
5252
};
5353

5454
if (waitForDebugger)

Apps/UnitTests/Source/Tests.NativeEngine.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ TEST(NativeEngine, ShaderCache)
3131
std::promise<void> scriptIsDone{};
3232
std::promise<void> sceneIsReady{};
3333

34-
Babylon::AppRuntime runtime{};
34+
Babylon::AppRuntime::Options options{};
35+
36+
options.UnhandledExceptionHandler = [&scriptIsDone](const Napi::Error& error) {
37+
std::cerr << "[Uncaught Error] " << Napi::GetErrorString(error) << std::endl;
38+
std::cerr.flush();
39+
40+
scriptIsDone.set_exception(std::make_exception_ptr(std::exception{}));
41+
};
42+
43+
Babylon::AppRuntime runtime{options};
3544
runtime.Dispatch([&device, &sceneIsReady](Napi::Env env) {
3645
device.AddToJavaScript(env);
3746

0 commit comments

Comments
 (0)