from gi.repository import GLib if some_error_occurs: GLib.Error("my-domain", GLib.ErrorEnum.ERROR_CODE, "Error message")
from gi.repository import GLib def some_function(): try: # do something that could cause a GLib error except GLib.Error as e: print("Error occurred: " + str(e)) some_function()In this example, if an error occurs within the `some_function()` function, the `GLib.Error` exception is caught, and a message is printed to the console. Package library: gobject-introspection.