Scenario
I have a custom rule to confirm the cost of order delivery:
public class OrderValidator : BaseValidator<Order> { private string CustomInfo { get; set; } public OrderValidator() {
In case of an exception, I save the exception information in a private CustomInfo element and add it to the verification message.
Then I run the validator:
OrderValidator oVal = new OrderValidator(); oVal.Results = oVal.Validate(order); if (!oVal.Results.IsValid) oVal.Results.Errors.ForEach(delegate(ValidationFailure error) { Console.WriteLine(error.ErrorMessage); });
Question
Everything works correctly, in case of an exception, CustomInfo is correctly set to ex.ToString (). But in the end, the error message displayed in the console does not display CustomInfo, but only the first part of the message:
"Shipping Cost not set or not correct: 5.9"
Question
Why doesn't the custom message contain a CustomInfo string? Can I add exception information to a custom message differently?
source share