Fix wrong instantiation of exceptions