generalized the catching of exceptions from the script