[gjs] gi: Improve error message when we get a non-function for a callback



commit 619abbfcf08e36dfe7262b47d4ab29863164a300
Author: Colin Walters <walters verbum org>
Date:   Wed Apr 25 12:07:59 2012 -0400

    gi: Improve error message when we get a non-function for a callback
    
    Print the type we received too
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674811

 gi/function.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index 51c90b9..576c755 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -787,10 +787,12 @@ gjs_invoke_c_function(JSContext      *context,
                     trampoline = NULL;
                 } else {
                     if (!(JS_TypeOfValue(context, value) == JSTYPE_FUNCTION)) {
-                        gjs_throw(context, "Error invoking %s.%s: Invalid callback given for argument %s",
+                        gjs_throw(context, "Error invoking %s.%s: Expected function for callback argument %s, got %s",
                                   g_base_info_get_namespace( (GIBaseInfo*) function->info),
                                   g_base_info_get_name( (GIBaseInfo*) function->info),
-                                  g_base_info_get_name( (GIBaseInfo*) &arg_info));
+                                  g_base_info_get_name( (GIBaseInfo*) &arg_info),
+                                  JS_GetTypeName(context,
+                                                 JS_TypeOfValue(context, value)));
                         failed = TRUE;
                         break;
                     }



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