A function wrapper for the classic try/catch statement in JavaScript, similar to the one in the Scala programming language.