handle error in open statement