throw/catch recovery

I'm a C programmer getting up to speed on C++, so this is probably a very simplistic question.

Assume a piece of code that detects something not quite right, so it wants to throw an exception describing the problem. Is there a way for the catch block to evaulate the situation and possibly decide it's not very important and just return to the line following the throw?

Here's an example scenario, but not what I'm trying to solve...

A command line option specifies which level of error should cause the program to stop, only log the error, or just ignore it and continue executing. It seems like this indicator would be kept at the catch code so it can be caught and handled in a consistent manner.

C++ doesn't seem to have this capability, or have I just missed it? It appears that I need to send down indicators (or pass an error handler function reference) to each object and they make the decision locally.

Am I missing something?

Bob
Why would you need to do that in the catch handler? Just make a function that takes the error level and error message, which then determines whether an exception will be thrown or not.
By the time you reach the catch handler, it's far too late - the stack unwinding has already taken place.
Assume a piece of code that detects something not quite right, so it wants to throw an exception describing the problem. Is there a way for the catch block to evaluate the situation and possibly decide it's not very important and just return to the line following the throw?
That's not how C++ exceptions work. You're describing the Resumption Model, C++ implements the Termination Model. Why? Because in the end, the termination model will be used. There was not enough evidence that the Resumption Model was necessary.

A command line option specifies which level of error should cause the program to stop, only log the error, or just ignore it and continue executing. It seems like this indicator would be kept at the catch code so it can be caught and handled in a consistent manner.
We wouldn't think of logging as an exceptional circumstance.

Am I missing something?
Not so much missing as misunderstanding.

The ideas is that you perform your code without worrying about serious error. No more checking the system allocator for failure and stuff like that.

You then handle the error at any level you want to, or ignore it complete where the default handler does something.
Topic archived. No new replies allowed.