throw some exceptions when invalid return code