Add try-catch function blocks in order to catch any top-level exception