Use right variable when throwing exception