Catch statements are being completely ignored

Since the catch (...) clause didn't catch the exception, my answer does not solve the OP's problem. But for others that found this question on SO, maybe my answer is useful, because it explains why the first catch failed.

I had a similar issue where my catch(const std::exception& ex) was just not working. It turned out to be a dumb problem in that I was switching between C# and C++ exceptions, and in C# you need to specify new when you throw your exception, while in C++ you normally don't (but you can, but in this case you are throwing a pointer and not a reference). I was accidentally doing

throw new std::runtime_error("foo");

so

catch(std::exception*  ex)

would have caught it but

catch(std::exception& ex)

doesn't. Of course, the solution is just remove the new statement, as that is not the traditional design pattern in C++.

Tags:

C++

Exception