Class GError
- All Implemented Interfaces:
Proxy
GError
structure contains information about
an error that has occurred.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Makes a copy of this Error.static Quark
domainRegister
(String errorTypeName, long errorTypePrivateSize, ErrorInitFunc errorTypeInit, ErrorCopyFunc errorTypeCopy, ErrorClearFunc errorTypeClear) This function registers an extendedGError
domain.static Quark
domainRegisterStatic
(String errorTypeName, long errorTypePrivateSize, ErrorInitFunc errorTypeInit, ErrorCopyFunc errorTypeCopy, ErrorClearFunc errorTypeClear) This function registers an extendedGError
domain.void
free()
Frees aGError
and associated resources.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the GError classstatic GError
Creates a newGError
; unlike g_error_new(),message
is not a printf()-style format string.boolean
Returnstrue
if this Error matchesdomain
andcode
,false
otherwise.int
readCode()
Read the value of the fieldcode
.Read the value of the fielddomain
.Read the value of the fieldmessage
.void
writeCode
(int code) Write a value in the fieldcode
.void
writeDomain
(Quark domain) Write a value in the fielddomain
.void
writeMessage
(String message, Arena _arena) Write a value in the fieldmessage
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
GError
Create a GError proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
GError
Creates a newGError
with the givendomain
andcode
, and a message formatted withformat
.- Parameters:
domain
- error domaincode
- error codeformat
- printf()-style format for error messagevarargs
- parameters for message format
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readDomain
Read the value of the fielddomain
.- Returns:
- The value of the field
domain
-
writeDomain
Write a value in the fielddomain
.- Parameters:
domain
- The new value for the fielddomain
-
readCode
public int readCode()Read the value of the fieldcode
.- Returns:
- The value of the field
code
-
writeCode
public void writeCode(int code) Write a value in the fieldcode
.- Parameters:
code
- The new value for the fieldcode
-
readMessage
Read the value of the fieldmessage
.- Returns:
- The value of the field
message
-
writeMessage
-
literal
Creates a newGError
; unlike g_error_new(),message
is not a printf()-style format string. Use this function ifmessage
contains text you don't have control over, that could include printf() escape sequences.- Parameters:
domain
- error domaincode
- error codemessage
- error message- Returns:
- a new
GError
-
domainRegister
public static Quark domainRegister(String errorTypeName, long errorTypePrivateSize, ErrorInitFunc errorTypeInit, ErrorCopyFunc errorTypeCopy, ErrorClearFunc errorTypeClear) This function registers an extendedGError
domain.errorTypeName
will be duplicated. Otherwise does the same as g_error_domain_register_static().- Parameters:
errorTypeName
- string to create aGQuark
fromerrorTypePrivateSize
- size of the private error data in byteserrorTypeInit
- function initializing fields of the private error dataerrorTypeCopy
- function copying fields of the private error dataerrorTypeClear
- function freeing fields of the private error data- Returns:
GQuark
representing the error domain
-
domainRegisterStatic
public static Quark domainRegisterStatic(String errorTypeName, long errorTypePrivateSize, ErrorInitFunc errorTypeInit, ErrorCopyFunc errorTypeCopy, ErrorClearFunc errorTypeClear) This function registers an extendedGError
domain.errorTypeName
should not be freed.errorTypePrivateSize
must be greater than 0.errorTypeInit
receives an initializedGError
and should then initialize the private data.errorTypeCopy
is a function that receives both original and a copyGError
and should copy the fields of the private error data. The standardGError
fields are already handled.errorTypeClear
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:
errorTypeName
- static string to create aGQuark
fromerrorTypePrivateSize
- size of the private error data in byteserrorTypeInit
- function initializing fields of the private error dataerrorTypeCopy
- function copying fields of the private error dataerrorTypeClear
- function freeing fields of the private error data- Returns:
GQuark
representing the error domain
-
copy
-
free
public void free()Frees aGError
and associated resources. -
matches
Returnstrue
if this Error matchesdomain
andcode
,false
otherwise. In particular, when this Error isnull
,false
will be returned.If
domain
contains aFAILED
(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 theFAILED
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- Returns:
- whether this Error has
domain
andcode
-