Add own InvalidException (fix #655)