Error handling

Sometimes things will fail. Make sure the script doesn't do anything crazy when they do.