Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introspection does not detect most error domains #109

Open
v1993 opened this issue Oct 21, 2023 · 7 comments
Open

Introspection does not detect most error domains #109

v1993 opened this issue Oct 21, 2023 · 7 comments

Comments

@v1993
Copy link

v1993 commented Oct 21, 2023

As of right now, only SourceError is properly declared as an error in generated files (see e.g. valadoc). This is a big issue for language bindings, since it removes the ability to (nicely) selectively catch exceptions from GUsb.

@v1993
Copy link
Author

v1993 commented Oct 21, 2023

I'm not quite sure if it's the cause of this issue, but it's worth noting that corresponding quark functions are appropriated by similarly named classes, e.g. Device.error_quark.

@hughsie
Copy link
Owner

hughsie commented Oct 23, 2023

Is it because the GUsbDevice error uses G_DEFINE_QUARK? the g_usb_source_error_quark() seems to be written out manually.

@v1993
Copy link
Author

v1993 commented Oct 23, 2023

That's plausible but would be pretty odd; G_DEFINE_QUARK is what official GLib docs recommend. It might have to do with header layout, although I'm not sure.

As an aside, I'm currently using a manually modified VAPI file on my end to work around this issue.

@hughsie
Copy link
Owner

hughsie commented Oct 23, 2023

As an aside, I'm currently using a manually modified VAPI file

Can you share what you're adding? I see

[CCode (cheader_filename = "gusb.h", cprefix = "G_USB_DEVICE_ERROR_", has_type_id = false)]
public enum DeviceError {
	INTERNAL,
	IO,
	TIMED_OUT,
	NOT_SUPPORTED,
	NO_DEVICE,
	NOT_OPEN,
	ALREADY_OPEN,
	CANCELLED,
	FAILED,
	PERMISSION_DENIED,
	BUSY,
	LAST
}

@v1993
Copy link
Author

v1993 commented Oct 23, 2023

All I do is replace enum with errordomain for affected domains. This is enough to get things working, although static quark() methods also, ideally, should be relocated there from classes they got stuck to.

@hughsie
Copy link
Owner

hughsie commented Oct 25, 2023

@v1993 If you can work out the fix I'm happy to review and then tag a new release.

@v1993
Copy link
Author

v1993 commented Oct 25, 2023

I'm currently bundling a modified vapi file with my application, which is good enough to get it working; hopefully will look into a proper fix later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants