I am using eclipse in Ubuntu 12.04. I use some exceptions in my program and when they are caught it gives me cout correctly. But the program continues to the end. Is there a way
The catch
handler in C++ allows one to handle the error outside the normal execution path for the code. Once handled, C++ assumes it is safe to resume normal operation or the program.
If this is not the case, say you just want to log the error, you are free to rethrow
the exception which causes to error to propagate further up the stack.
If the exception does not get caught at all, the C++ function std::terminate
will get called. The default behavior is to call abort
.
Is probably the best thing to do you your case is just rethrow the exeception by calling throw
at the end of the catch block.