[gjs: 4/6] gjs_context_eval: Use different GError message for uncatchable exceptions



commit 29586dd32c53d8ddbe7db3e01310e2bc99c86068
Author: Simon McVittie <smcv debian org>
Date:   Tue Jan 30 08:31:44 2018 +0000

    gjs_context_eval: Use different GError message for uncatchable exceptions
    
    Callers should have the opportunity to distinguish between an
    ordinary exception and an uncatchable exception. gjs_log_exception()
    isn't necessarily going to give us anything useful for an
    uncatchable exception.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 gjs/context.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 62c1845d..bdeda42d 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -795,11 +795,16 @@ gjs_context_eval(GjsContext   *js_context,
             goto out;  /* Don't log anything */
         }
 
+        if (!JS_IsExceptionPending(js_context->context)) {
+            g_set_error(error, GJS_ERROR, GJS_ERROR_FAILED,
+                        "Script %s terminated with an uncatchable exception",
+                        filename);
+        } else {
+            g_set_error(error, GJS_ERROR, GJS_ERROR_FAILED,
+                        "Script %s threw an exception", filename);
+        }
+
         gjs_log_exception(js_context->context);
-        g_set_error(error,
-                    GJS_ERROR,
-                    GJS_ERROR_FAILED,
-                    "JS_EvaluateScript() failed");
         /* No exit code from script, but we don't want to exit(0) */
         *exit_status_p = 1;
         goto out;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]