[Vala] Error handling documentation
- From: Roman Harin <HarinRoman 3dsyatoe ru>
- To: vala-list gnome org
- Subject: [Vala] Error handling documentation
- Date: Mon, 12 Apr 2010 18:21:43 +0400
Hi,
It's seem to not enought documentation at
http://live.gnome.org/Vala/Tutorial#Error_Handling about error codes.
I suppose this may help:
/* valac vala_err_code.vala */
errordomain ErrorType1 {
CODE_1A
}
errordomain ErrorType2 {
CODE_2A,
CODE_2B,
CODE_2C
}
public class Test : GLib.Object {
public static void thrower() throws ErrorType1, ErrorType2 {
//throw new ErrorType1.CODE_1A("Error CODE_1A");
throw new ErrorType2.CODE_2A("Error CODE_2A");
//throw new ErrorType2.CODE_2B("Error CODE_2B");
//throw new ErrorType2.CODE_2C("Error CODE_2C");
}
public static void catcher() throws ErrorType2 {
try {
thrower();
} catch (ErrorType1 e) {
// Deal with ErrorType1
print("Catch ErrorType1\n");
} finally {
// Tidy up
}
}
public static int main(string[] args) {
try {
catcher();
} catch (ErrorType2.CODE_2A e) {
print("Catch ErrorType2.CODE_2A\n");
} catch (ErrorType2 e) {
// Deal with ErrorType2
if (e is ErrorType2.CODE_2B) {
print("Catch ErrorType2.CODE_2B\n");
} else
print("Catch ErrorType2 (code=%d)\n", e.code);
}
return 0;
}
}
--
Роман Харин <HarinRoman 3dsyatoe ru>
jabber://harinr jabber ru
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]