1.9 <GError>

Structure: <GError>

The <GError> structure contains information about an error that has occurred.

Fields

domain

error domain, e.g. G_FILE_ERROR

code

error code, e.g. noent

message

human-readable informative error message

Procedures

Method: error:copy self ⇒ %return
Method: copy self ⇒ %return

Makes a copy of self.

self

Passed: a <GError>.

a <GError>

%return

Returned: a <GError>.

a new <GError>

Procedure: error:domain-register error-type-name error-type-private-size error-type-init error-type-copy error-type-clear ⇒ %return

This function registers an extended <GError> domain. error-type-name will be duplicated. Otherwise does the same as error-domain-register-static.

error-type-name

Passed: a string.

string to create a GQuark from

error-type-private-size

Passed: an unsigned 64-bit integer.

size of the private error data in bytes

error-type-init

Passed: a procedure.

function initializing fields of the private error data

See GErrorInitFunc for how it is called.

error-type-copy

Passed: a procedure.

function copying fields of the private error data

See GErrorCopyFunc for how it is called.

error-type-clear

Passed: a procedure.

function freeing fields of the private error data

See GErrorClearFunc for how it is called.

%return

Returned: an unsigned 32-bit integer.

GQuark representing the error domain

Procedure: error:domain-register-static error-type-name error-type-private-size error-type-init error-type-copy error-type-clear ⇒ %return

This function registers an extended <GError> domain.

error-type-name should not be freed. error-type-private-size must be greater than 0.

error-type-init receives an initialized <GError> and should then initialize the private data.

error-type-copy is a function that receives both original and a copy <GError> and should copy the fields of the private error data. The standard <GError> 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.

error-type-name

Passed: a string.

static string to create a GQuark from

error-type-private-size

Passed: an unsigned 64-bit integer.

size of the private error data in bytes

error-type-init

Passed: a procedure.

function initializing fields of the private error data

See GErrorInitFunc for how it is called.

error-type-copy

Passed: a procedure.

function copying fields of the private error data

See GErrorCopyFunc for how it is called.

error-type-clear

Passed: a procedure.

function freeing fields of the private error data

See GErrorClearFunc for how it is called.

%return

Returned: an unsigned 32-bit integer.

GQuark representing the error domain

Method: error:free self
Method: free self

Frees a <GError> and associated resources.

self

Passed: a <GError>.

a <GError>

Method: error:matches? self domain code ⇒ %return
Method: matches? self domain code ⇒ %return

Returns #t if self matches domain and code, #f otherwise. In particular, when self is #f, #f 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.

self

Passed: a <GError>.

a <GError>

domain

Passed: an unsigned 32-bit integer.

an error domain

code

Passed: a 32-bit integer.

an error code

%return

Returned: a boolean.

whether self has domain and code

Procedure: error:new-literal domain code message ⇒ %return

Creates a new <GError>; 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.

domain

Passed: an unsigned 32-bit integer.

error domain

code

Passed: a 32-bit integer.

error code

message

Passed: a string.

error message

%return

Returned: a <GError>.

a new <GError>