One try{} catch{} finally{} construct is tolerably clear. But what about more nested trys?
I often try to code so, that I leave the function in case of an error as soon as possible. A dozen nested if-else statements is not clear at all and a dozen try blocks is even worse.
int myfunc(void)
{
if (errorvalue == func1()) {
finalize();
return 0;
}
if (errorvalue == func2()) {
finalize();
return 0;
}
if (errorvalue == func3()) {
finalize();
return 0;
}
// do what I actually want to do
return 1;
}
It is sure, that one can not stand this in all cases, but I can often reduce the nesting complexity considerably.
czerny