Avoid Else, Return Early (2013)
Error handling early on with a throw or return is so much better because it just allows you to stop thinking the very moment you need to stop caring about the remainder of the function.It's very much like any logic or debate, where you simply want to prevent getting into any of the details that occur further down the logical chain if you can already dismiss what is to come by detecting the exit condition early. There have been countless occasions where I've heard people having conversations for hours that should failed and exited early due to an exit condition at the very beginning of the conversation.