fix exception not thrown correctly