Added exception handling when running scripts.