I did have a check, however, the cleanup code that runs when the script fails is what was running into errors. Fixed the cleanup code.