The example code (both examples actually) should return after printing the error. Sorry, had to be that guy.
Was this posted by the author?
No. I've used this yesterday and it was very useful for what I was doing. Thought it would be of interest to others.
For whoever downvoted me, I was asking because I wanted to know if I could directly ask them questions on this thread. I don't have a problem with self-promotion.