[Interest] Recommended exception handling

Thiago Macieira thiago.macieira at intel.com
Tue Mar 12 02:04:45 CET 2019


On Monday, 11 March 2019 13:41:11 PDT Konstantin Shegunov wrote:
> Hello,
> Is there a current recommended way of catching exceptions before they
> unwind through the event loop? 

Yes: just catch them before letting them come back to any Qt function. You 
should treat all your slots and event handlers as "noexcept" (you may even 
want to mark them as such).

> I want this for "debug purposes" only. I
> have few methods that throw and I (think I) catch (all of) my exceptions
> before they reach the event loop, but I wanted to be sure I hadn't
> forgotten something somewhere. Shouldn't happen anyway, but I was wondering
> if there's (or if there's going to be) a replacement
> for QCoreApplication::notify.

The advice for QCoreApplication::notify is no longer valid. If an exception 
escapes, BadThings™ will happen. Your application may crash before getting to 
notify(), or abort by std::terminate(). Or it may cause data corruption.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products






More information about the Interest mailing list