3 ms·
A good example of valid use of catch_unwind() would be for a desktop app to try to save a copy of any unsaved in-memory state before it crashes for good. Since
by int_19h 2y ago
A good example of valid use of catch_unwind() would be for a desktop app to try to save a copy of any unsaved in-memory state before it crashes for good. Since invariants are already broken, it might or might not work, and may possibly save some garbage data, but it is much better than saving nothing at all.
The one common thing for all such patterns is that they happen at or near the topmost layer of the app (e.g. around the main loop for GUI apps, or around the request handler for web apps).