summaryrefslogtreecommitdiff
path: root/gjs
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2022-05-21 22:53:40 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2022-08-07 21:36:29 -0700
commit330ae5d67867ea9fff97f733f9219921ae22bf19 (patch)
tree849a082df9c7888b68222d78a5ac8ff8f86f5d59 /gjs
parentf22c98e8e387bd320b919ea34a18860341173239 (diff)
downloadgjs-330ae5d67867ea9fff97f733f9219921ae22bf19.tar.gz
engine: Use JS_InitWithFailureDiagnostic instead of JS_Init
No difference between these two, except that JS_InitWithFailureDiagnostic returns a descriptive message if it fails, which JS_Init ignores. So, in the rare case that it fails, we abort while printing the descriptive message instead of just "Could not initialize JavaScript".
Diffstat (limited to 'gjs')
-rw-r--r--gjs/engine.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index d0f05e7d..a8e867a7 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -89,10 +89,13 @@ LPVOID lpvReserved)
{
switch (fdwReason)
{
- case DLL_PROCESS_ATTACH:
- gjs_dll = hinstDLL;
- gjs_is_inited = JS_Init();
- break;
+ case DLL_PROCESS_ATTACH: {
+ gjs_dll = hinstDLL;
+ const char* reason = JS_InitWithFailureDiagnostic();
+ if (reason)
+ g_error("Could not initialize JavaScript: %s", reason);
+ gjs_is_inited = true;
+ } break;
case DLL_THREAD_DETACH:
JS_ShutDown ();
@@ -110,8 +113,9 @@ LPVOID lpvReserved)
class GjsInit {
public:
GjsInit() {
- if (!JS_Init())
- g_error("Could not initialize Javascript");
+ const char* reason = JS_InitWithFailureDiagnostic();
+ if (reason)
+ g_error("Could not initialize JavaScript: %s", reason);
}
~GjsInit() {