don't print error message until after checking exception type