handle error in handleError func