
Signature
Jon Biggar
Floorboard Software
jon@floorboard.com
jon@biggar.org
> >> Just write your own wrapper function that calls non_existent(), catches
> >> the exceptions you want, and returns different error codes for different
[quoted text clipped - 6 lines]
> Not if you design the error codes right, or make predicate functions
> that you can reuse that translate the error code to a boolean value.
As long as your wrapper "returns different error codes for different
exceptions".
Here is an example:
original code with many try/catch:
try {
....
}
catch(exception a) {
handle_exception_a(...);
}
catch(exception b) {
handle_exception_b(...);
}
...
wrapper that "returns different error codes for different exceptions":
...
int wrapper() {
...
try {
....
}
catch(exception a) {
return error_code_a;
}
catch(exception b) {
return error_code_b;
}
...
}
Use of this wrapper:
...
switch(wrapper()) {
case error_code_a: handle error a; break;
case error_code_b: handle error b; break;
...
}
Regards,
Ke
> --
> Jon Biggar
> Floorboard Software
> jon@floorboard.com
> jon@biggar.org
Jonathan Biggar - 25 Jan 2007 18:48 GMT
>>>> Just write your own wrapper function that calls non_existent(), catches
>>>> the exceptions you want, and returns different error codes for different
[quoted text clipped - 7 lines]
> As long as your wrapper "returns different error codes for different
> exceptions".
You're missing my point.
> Here is an example:
>
[quoted text clipped - 36 lines]
> ...
> }
Or:
bool error_codes_i_care_about(error code e) {
switch (e) {
case error_code_a:
case error_code_c:
return true;
default:
return false;
}
}
error_code wrapper(CORBA::Object_ptr obj) {
try {
....
}
catch(exception a) {
return error_code_a;
}
catch(exception b) {
return error_code_b;
}
...
}
bool wrapper(CORBA::Object_ptr obj, bool (*predicate)(errror_code)) {
return predicate(wrapper(obj));
}
...
if (wrapper(obj, error_codes_i_care_about)) {
// handle errors I care about
else
// do something else
...

Signature
Jon Biggar
Floorboard Software
jon@floorboard.com
jon@biggar.org