fixing a potential exception thrown by throwing an exception