Обработка ошибок
void my_method() throws IOError {
// ...
}if (something_went_wrong) {
throw new IOError.FILE_NOT_FOUND("Requested file could not be found.");
}try {
my_method();
} catch (IOError e) {
stdout.printf("Error: %s\n", e.message);
}IOChannel channel;
try {
channel = new IOChannel.file("/tmp/my_lock", "w");
} catch (FileError e) {
if(e is FileError.EXIST) {
throw e;
}
GLib.error("", e.message);
}Last updated
Was this helpful?