GLib.Error¶
record (struct)
The GError structure contains information about
an error that has occurred.
Constructors¶
new_literal¶
Creates a new Error; unlike g_error_new(), message is
not a printf()-style format string. Use this function if
message contains text you don't have control over,
that could include printf() escape sequences.
Parameters:
domain— error domaincode— error codemessage— error message
Methods¶
copy¶
Makes a copy of error.
free¶
Frees a Error and associated resources.
matches¶
Returns True if error matches domain and code, False
otherwise. In particular, when error is None, False will
be returned.
If domain contains a FAILED (or otherwise generic) error code,
you should generally not check for it explicitly, but should
instead treat any not-explicitly-recognized error code as being
equivalent to the FAILED code. This way, if the domain is
extended in the future to provide a more specific error code for
a certain case, your code will still work.
Parameters:
domain— an error domaincode— an error code
Static functions¶
domain_register¶
@staticmethod
def domain_register(error_type_name: str, error_type_private_size: int, error_type_init: ErrorInitFunc, error_type_copy: ErrorCopyFunc, error_type_clear: ErrorClearFunc) -> Quark
This function registers an extended Error domain.
error_type_name will be duplicated. Otherwise does the same as
Error.domain_register_static.
Parameters:
error_type_name— string to create aGQuarkfromerror_type_private_size— size of the private error data in byteserror_type_init— function initializing fields of the private error dataerror_type_copy— function copying fields of the private error dataerror_type_clear— function freeing fields of the private error data
domain_register_static¶
@staticmethod
def domain_register_static(error_type_name: str, error_type_private_size: int, error_type_init: ErrorInitFunc, error_type_copy: ErrorCopyFunc, error_type_clear: ErrorClearFunc) -> Quark
This function registers an extended Error domain.
error_type_name should not be freed. error_type_private_size must
be greater than 0.
error_type_init receives an initialized Error and should then initialize
the private data.
error_type_copy is a function that receives both original and a copy
Error and should copy the fields of the private error data. The standard
Error fields are already handled.
error_type_clear receives the pointer to the error, and it should free the
fields of the private error data. It should not free the struct itself though.
Normally, it is better to use G_DEFINE_EXTENDED_ERROR(), as it already takes care of passing valid information to this function.
Parameters:
error_type_name— static string to create aGQuarkfromerror_type_private_size— size of the private error data in byteserror_type_init— function initializing fields of the private error dataerror_type_copy— function copying fields of the private error dataerror_type_clear— function freeing fields of the private error data