Is there any way to get at least some information inside of here?
...
catch(...)
{
std::cerr << "Unhandled exception" << std::endl;
}
I have this as a last resort around all my code. Would it be better to let it crash, because then I at least could get a crash report?
No, there isn't any way. Try making all your exception classes derive from one single class, like std::exception
, and then catch that one.
You could rethrow in a nested try
, though, in an attempt to figure out the type. But then you could aswell use a previous catch clause (and ...
only as fall-back).
You can do this using gdb or another debugger. Tell the debugger to stop when any exception is throw (in gdb the command is hilariously catch throw
). Then you will see not only the type of the exception, but where exactly it is coming from.
Another idea is to comment out the catch (...)
and let your runtime terminate your application and hopefully tell you more about the exception.
Once you figure out what the exception is, you should try to replace or augment it with something that does derive from std::exception
. Having to catch (...)
at all is not great.
If you use GCC or Clang you can also try __cxa_current_exception_type()->name()
to get the name of the current exception type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With