how to handle error in python