Checking exception when trying to save invalid object