[gjs] Log errors that occur in callbacks



commit d8636c899f69c115d0051c396c0864379880d981
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun May 9 16:25:28 2010 -0400

    Log errors that occur in callbacks
    
    If an exception occurs in a callback, instead of leaving the exception
    set in the JS context (which often result in the exception
    disappearing off into the ether), log and clear it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618200

 gi/function.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index 1eb0972..510707e 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -150,6 +150,7 @@ gjs_callback_closure(ffi_cif *cif,
     int i, n_args, n_jsargs;
     jsval *jsargs, rval;
     GITypeInfo ret_type;
+    gboolean success = FALSE;
 
     trampoline = data;
     g_assert(trampoline);
@@ -183,7 +184,6 @@ gjs_callback_closure(ffi_cif *cif,
                               n_jsargs,
                               jsargs,
                               &rval)) {
-        gjs_throw(trampoline->context, "Couldn't call callback");
         goto out;
     }
 
@@ -197,11 +197,16 @@ gjs_callback_closure(ffi_cif *cif,
                                  FALSE,
                                  TRUE,
                                  result)) {
-        gjs_throw(trampoline->context, "Couldn't convert res value");
         result = NULL;
+        goto out;
     }
 
+    success = TRUE;
+
 out:
+    if (!success)
+        gjs_log_exception (trampoline->context, NULL);
+
     if (trampoline->scope == GI_SCOPE_TYPE_ASYNC) {
         completed_trampolines = g_slist_prepend(completed_trampolines, trampoline);
     }



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