Tip: Gracefully handle exceptions by introducing the same exception

Temporarily add the same exception

The trick is really quite simple. The diagnostics will typically at least tell you where the exception originated from. So rather than recreating the exception by trying to get the system into the same state, simple add code to throw/raise exception at the same point. This way you can create the same flow of exception handlers and ensure the code gracefully continues without causing the application any serious problems. Once the exception is handled correctly remember to remove the artificial exception :)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store