Thanks all,

My script works. I was testing it with syntax error instead of simulating an execution error.