Catch all optimizer expections and reraise them as a general exception