Error
Object Hierarchy:
Description:
[ Compact ]
[ ErrorBase ]
[ CCode ( copy_function = "g_error_copy" , free_function = "g_error_free" , type_id = "G_TYPE_ERROR" ) ]
public class Error
The `GError` structure contains information about an error that has occurred.
Example: Exception sample:
public static void dummy () throws FileError {
throw new FileError.ACCES ("My error msg");
}
public static int main (string[] args) {
try {
dummy ();
} catch (FileError e) {
// Output:
// ``Message: "My error msg"``
// ``Error code: FileError.EXIST = 2``
// ``FileErrors identification: 51``
print ("Message: \"%s\"\n", e.message);
print ("Error code: FileError.EXIST = %d\n", e.code);
print ("FileErrors identification: %" + uint32.FORMAT + "\n", e.domain);
return 0;
}
assert_not_reached ();
}
valac --pkg glib-2.0 GLib.Error.vala
Content:
Static methods:
- public static void @set (out Error? dest, Quark domain, int code, string format, ...)
Does nothing if err
is null;
if err
is non-null, then *err
must be null.
- public static void prefix (out Error? dest, string format, ...)
Formats a string according to format
and prefix it to an
existing error message.
- public static void prefix_literal (out Error? dest, string prefix)
Prefixes prefix
to an existing error message.
- public static void propagate (out Error? dest, owned Error src)
If dest
is null, free
src
; otherwise, moves src
into *dest
.
- public static void propagate_prefixed (out Error? dest, owned Error src, string format, ...)
If dest
is null, free
src
; otherwise, moves src
into *dest
.
- public static void set_literal (out Error? dest, Quark domain, int code, string message)
Does nothing if err
is null;
if err
is non-null, then *err
must be null.
Creation methods:
- public Error (Quark domain, int code, string format, ...)
Creates a new Error with the given domain
and code
, and a message formatted with format
.
- public Error.literal (Quark domain, int code, string message)
Creates a new Error; unlike
Error, message
is not a
printf-style format string.
- public Error.valist (Quark domain, int code, string format, va_list args)
Creates a new Error with the given domain
and code
, and a message formatted with format
.
Methods:
Fields: