Paste: clay exceptions
Author: | kssreeram |
Mode: | text |
Date: | Wed, 28 Jul 2010 03:05:59 |
Plain Text |
testException1(x) {
try {
doSomething(x);
}
catch (e:Error1) {
println(e);
}
catch (e:Error2) {
println(e);
}
catch (e:Int) {
println("error code = ", e);
}
}
is roughly equivlalent to:
testException1(x) {
try {
doSomething(x);
}
catch {
if (exceptionIs?(Error1)) {
var e = exceptionAs(Error1);
println(e);
}
else if (exceptionIs?(Error2)) {
var e = exceptionAs(Error2);
println(e);
}
else if (exceptionIs?(Int)) {
var e = exceptionAs(Int);
println("error code = ", e);
}
else {
continueException();
}
}
}
exceptionIs?, exceptionAs, and continueException are clay library routines.
http://bitbucket.org/kssreeram/clay/src/3d43afc42b86/lib-clay/exceptions/exceptions.clay
New Annotation