Treat the running procss like a hot potato. You want to minimize how much time the process spends in your function to minimize hitting any landmines. The longer something lives, the more errors accumulate.
Returning early lends itself well to minimizing nesting. Instead of handling a success condition in a nested if statement. Return early or throw an exception early for an error condition so you don't have to nest the success condition at all. Nested code is harder to read and by nature more complicated than small simple if conditions. The top of a f