How to catch every exception in a multi-threaded C++ app with the minumum of code?

  softwareengineering

I have been tasked with the title above. There is currently zero exception handling. There are 100+ threads, all created from main().

Exceptions won’t percolate up to main() – they won’t leave the thread.

Each thread has a Make() function, invoked from main(), which initializes the data and subscribes to async messages. The system framework delivers the messages by invoking callbacks which were passed in the subscribe() function.

I don’t think that I can wrap each thread in its own try catch. I fear that I must have a try/catch in each message handler, and management would baulk at that, as each thread has a dozen or so subscribed messages, meaning adding 1,000+ try/catch.

Is there a simpler solution, using C++ 14? Host is Windows and target is VxWorks, if that makes any difference.

LEAVE A COMMENT