Exception Handling C++

Hello All,

I have a question ....which I am totally confused about!

If I have a fxn foo in a program which returns a logical value. But it has a posssiblity to throw some exception.

Now my exception handler returns a value as a string stating why the exception occured.

But my function can return only logical value !!!!!

How to handle that Exception !!!! For eg.

 
logical foo()
{
try
{
.....
.....
}
catch( Exception& e)
{
return e.show(); //bt. this would return a char* and not a logical value ..so not sure how it would work!!!
}
}
 
//So the way I am doing is ...the folloing ...bt. not sure ...if this is the correct way of doing it!!!
 
logical foo()
{
try
{
....
...
}
catch(Exception &)
{
return false;
}
}

Thank you for helping !!!

If your function has no way of returning errors, you shouldn't catch the exception, just let it happen. Whatever's calling the function can catch it instead.

If possible it'd be better to modify your function to properly return an error when necessary. Java utility functions throw errors instead of returning error codes all the time and it makes error handling a royal pain. It amounts to a weird anonymous goto where you don't know the source or destination.