[seed] Implement seed_closure_warn_exception, for dealing with unhandled exceptions in closures.



commit a2363a8f63ec5f6351cac5a420a2cab3c13d0190
Author: Robert Carr <racarr svn gnome org>
Date:   Mon May 11 17:44:48 2009 -0400

    Implement seed_closure_warn_exception, for dealing with unhandled exceptions in closures.
---
 doc/reference/Makefile.am |    2 +-
 libseed/seed-closure.c    |   17 +++++++++++++++++
 libseed/seed-closure.h    |    5 +++++
 libseed/seed.h            |    3 +++
 4 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index ddb15ef..8db4e9f 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -67,7 +67,7 @@ expand_content_files=
 # signals and properties.
 # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
 # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
-INCLUDES=
+INCLUDES= 
 GTKDOC_LIBS=
 
 # This includes the standard gtk-doc make rules, copied by gtkdocize.
diff --git a/libseed/seed-closure.c b/libseed/seed-closure.c
index 217aafd..9f0c6bb 100644
--- a/libseed/seed-closure.c
+++ b/libseed/seed-closure.c
@@ -392,6 +392,23 @@ seed_make_gclosure (JSContextRef ctx, JSObjectRef function, JSObjectRef user_dat
   return closure;
 }
 
+void
+seed_closure_warn_exception (GClosure *c,
+			     JSContextRef ctx,
+			     JSValueRef exception)
+{
+  JSObjectRef callable = seed_closure_get_callable (c);
+  gchar *name = seed_value_to_string (ctx, 
+				      seed_object_get_property (ctx, callable, "name"),
+				      NULL);
+  gchar *mes = seed_exception_to_string (ctx, exception);
+
+  g_warning("Exception in closure (%p %s). %s", c, name, mes);
+  
+  g_free (name);
+  g_free (mes);   
+}
+
 JSClassDefinition seed_native_callback_def = {
   0,				/* Version, always 0 */
   0,
diff --git a/libseed/seed-closure.h b/libseed/seed-closure.h
index aea4a5d..57797bd 100644
--- a/libseed/seed-closure.h
+++ b/libseed/seed-closure.h
@@ -62,6 +62,11 @@ seed_closure_invoke (GClosure *closure, JSValueRef *args, guint argc, JSValueRef
 JSValueRef
 seed_closure_invoke_with_context (JSContextRef ctx, GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception);
 
+void
+seed_closure_warn_exception (GClosure *c,
+			     JSContextRef ctx,
+			     JSValueRef exception);
+
 
 
 void seed_closures_init ();
diff --git a/libseed/seed.h b/libseed/seed.h
index f57a128..3df71fb 100644
--- a/libseed/seed.h
+++ b/libseed/seed.h
@@ -404,5 +404,8 @@ seed_closure_invoke (GClosure *closure, SeedValue *args, guint argc, SeedExcepti
 SeedValue
 seed_closure_invoke_with_context (SeedContext ctx, GClosure *closure, SeedValue *args, guint argc, SeedException *exception);
 
+void
+seed_closure_warn_exception (GClosure *c, SeedContext ctx, SeedException exception);
+
 
 #endif



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