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?
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 ofstd::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 exitsmain(). You can try wrapping yourmain()code intry...catchto print the exception’sdisplayText().... functionname(...) throw(...)). This will callstd::unexpected()which in turn will callstd::terminate()(by default).When using Poco threads and a thread is terminated by an unhandled exception, Poco will invoke its internal
ErrorHandlerand the program will not exit, so I doubt that this is a threading issue.