I was doing some messing around with exceptions, to test whether they did what I wanted, and to get a better feel for how they work. I was surprised that I could generate exceptions, but neither catch(exception &ex) nor catch(...) would catch them.
When I examined one closer, it looks like a win32 exception (Integer divide by zero, or something like that, there is no such thing in C++ right?).
So would you say that catch(...) only catches C++ language exceptions, but bad code can generate system exceptions that are not part of the C++ language and therefore can't be caught?
Also, what is the difference between a range_error and an out_of_range error? I see one is a logic error, and one is runtime error. But if you are throwing them yourself, it's not that clear to me how important that distinction is, or how you would make it. Is the runtime version something used for bad parameters, while logic version is for like when something is incremented/deincremented past the largest or smallest value?
So would you say that catch(...) only catches C++ language exceptions, but bad code can generate system exceptions that are not part of the C++ language and therefore can't be caught?
This is correct.
When I examined one closer, it looks like a win32 exception (Integer divide by zero, or something like that, there is no such thing in C++ right?).
Yes, Microsoft has something that they call exceptions but are different from normal C++ exceptions. The C++ standard just says that if you divide an integer by zero the behavior is undefined, which means anything could happen.
what is the difference between a range_error and an out_of_range error?
This is what the C++ standard have to say.
The class out_of_range defines the type of objects thrown as exceptions to report an argument value not in its expected range.
The class range_error defines the type of objects thrown as exceptions to report range errors in internal computations.