Ending a call after calling an instance of "Poco :: SystemException"

Sometimes (about 1 out of 100 starts) my program terminates this message:

terminate called after throwing an instance of 'Poco::SystemException' what(): System exception 

my code is not the one who catches the exception (all my catches are more detailed), and I'm not sure where it caught. it is very likely that the exception contains a useful message, but it is not returned via the what () method, but by the displayText () method.

The string "terminate called after throwing instance of" has ~ 600k on Google, so it is probably printed by code inserted by the compiler or some common library (pthread?). I only saw this error message when the program was running on Linux (never on Windows).

Does anyone know in which code this caught exception is caught?

+4
source share
2 answers

Does anyone know in which code this caught exception is caught?

An uncaught exception, by definition, is not caught anywhere.

If the exception cannot be handled, the C ++ exception mechanism will call std::terminate() (see the <exception> header), which will call the custom completion handler. On your platform, the standard print completion handler outputs std::exception::what() (to which Poco exceptions are inherited). Unfortunately, methods for eliminating Poco are developed; this will not contain any useful information.

There are several ways to eliminate the exception:

  • No suitable catch() handler was found, and the promotion mechanism terminates main() . You can try wrapping the main() code in try...catch to print a displayText() exception.
  • The function terminates with an exception that does not meet the specification of the exception ( ... functionname(...) throw(...) ). This will call std::unexpected() , which in turn will call std::terminate() (by default).
  • The exception is selected from the destructor, which is called during the process of unwinding another exception. Never throw exceptions in destructors!
  • When you try to create a source exception object, an exception is thrown. Never throw exceptions in custom exception classes!

When using Poco streams and the thread is interrupted by an unhandled exception, Poco will call its internal ErrorHandler , and the program will not, therefore, I doubt that this is a problem with the streams.

+12
source

I was getting the same error. I used the catch try block in the run function of the Poco :: Runnable class. I removed the catch try block from this class and used a derivative of the Poco :: ErrorHandler class to handle errors. After that, I stopped this error.

0
source

All Articles