Sometimes (about 1 out of 100 runs), my program terminates with this message:
terminate called after throwing an instance of 'Poco::SystemException'
what(): System exception
my code is not the one catching the exception (all my catches are more verbose), and I am not sure where it's caught. it's very likely that the exception does contain a useful message, but it's not returned through the what() method but by the displayText() method.
The string "terminate called after throwing an instance of" has ~600k in Google, so it's probably printed by code inserted by the compiler or by some common library (pthread?). I only seen this error message when the program ran on Linux (never on Windows).
anyone knows in what code this uncaught exception is caught?
anyone knows in what code this uncaught exception is caught?
An uncaught exception is—by definition—not caught anywhere.
If an exception cannot be handled, the C++ exception mechanism will call std::terminate()
(see include header <exception>
), which will call a customizable termination handler. On your platform, the standard termination handler prints the output of std::exception::what()
(which Poco's exceptions inherit from). Unfortunately, the way Poco's exceptions are designed, this will not contain any useful information.
There are multiple ways an exception cannot be handled:
catch()
handler is found and the unwinding mechanism exits main()
. You can try wrapping your main()
code in try...catch
to print the exception's displayText()
.... functionname(...) throw(...)
). This will call std::unexpected()
which in turn will call std::terminate()
(by default).When using Poco threads and a thread is terminated by an unhandled exception, Poco will invoke its internal ErrorHandler
and the program will not exit, so I doubt that this is a threading issue.
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