After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698182 - Gio.query_file_type error message is really confusing
Gio.query_file_type error message is really confusing
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-17 08:55 UTC by romu
Modified: 2013-04-19 15:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Improve error message when passing objects to flags (4.43 KB, patch)
2013-04-17 17:04 UTC, Giovanni Campagna
committed Details | Review

Description romu 2013-04-17 08:55:54 UTC
Let's try the following code:

Gio.query_file_type(null, null);

This output the following error:
Unexpected unregistered type unpacking GArgument from Object

With the additional message:
Exception was set even though JS_EvaluateScript() returned true - did you gjs_throw() but not return false somewhere perhaps?

Such a message is really confusing and doesn't help at all to find the fix.
Comment 1 Giovanni Campagna 2013-04-17 16:21:22 UTC
This is what I get:
TypeError: imports.gi.Gio.query_file_type is not a function

And rightly so, the function actually is:
Gio.File.prototype.query_file_type();

And even better, if I call it directly (without using .call()), I get:
TypeError: Object 0x7fbcaee328e0 is not a subclass of GObject_Object, it's a GObject_Interface
Comment 2 romu 2013-04-17 16:39:41 UTC
Forgot to say I'm still running Gnome 3.6.2.

The exact code was: http://fpaste.org/PXKi/
Comment 3 Giovanni Campagna 2013-04-17 17:03:44 UTC
Ok, with this it becomes reproducible in master too.

For the record, the error is that you're calling query_file_type(null, null), while you should call query_file_type(0, null).
Patch coming.
Comment 4 Giovanni Campagna 2013-04-17 17:04:38 UTC
Created attachment 241760 [details] [review]
Improve error message when passing objects to flags

Instead of complaining that we don't know how to handle an unregistered
type from an object (unregistered because of a missing enum value in the
switch), recognize that for enum and flags types we expect a number,
and report a type mismatch.

After the patch, the error becomes:
Expected type flags for Argument 'flags' but got type 'object'
Comment 5 Jasper St. Pierre (not reading bugmail) 2013-04-17 17:08:33 UTC
Review of attachment 241760 [details] [review]:

OK.
Comment 6 romu 2013-04-17 18:29:09 UTC
I know Giovanni, it took me a while to find the correct form:
this._folder.query_file_type(Gio.FileQueryInfoFlags.NONE, null)

Thanks guys, you're damned quick!
Comment 7 Giovanni Campagna 2013-04-19 15:15:38 UTC
Attachment 241760 [details] pushed as b5d40cb - Improve error message when passing objects to flags