Handling ElementNotFound exception when validating
Posted: Wed Oct 12, 2016 1:04 am
I'm a little confused about something.
When using Validate.Exists(), we can pass in an Element and a bool specifying whether to throw an exception if the validation fails.
What I don't get is why we can choose to throw an exception or not for this particular case. If it does not find the Element, it will still throw an ElementNotFound exception.
Is there any way to disable or handle the ElementNotfound exception? We have many, many elements to validate and the default message for the Element validation, which explicitly uses the items name, is much better and more informative than the default message for the RepoItemInfo validation, which is 'Self' for all of them.
Thanks.
When using Validate.Exists(), we can pass in an Element and a bool specifying whether to throw an exception if the validation fails.
What I don't get is why we can choose to throw an exception or not for this particular case. If it does not find the Element, it will still throw an ElementNotFound exception.
Is there any way to disable or handle the ElementNotfound exception? We have many, many elements to validate and the default message for the Element validation, which explicitly uses the items name, is much better and more informative than the default message for the RepoItemInfo validation, which is 'Self' for all of them.
Thanks.