At the start of your script use...
Set Error Capature [ON]
Your script here...
Set Error Capture [OFF] at exit of script
Wow. Easy enough. Thanks. I've been through the help files, The Missing Manual and Lynda.com. I'll start here first next time.
(BTW: the error capture will turn 'On' again once the script has run, so you can omit that step, if it is the last step.)