When a date like "2017-06-27" is inside of a large XML document containing many other dates and stings to be deserialized, a System.FormatException is thrown with the message "String was not recognized as a valid DateTime." Similar exceptions are thrown for Boolean.Parse, Guid.Parse, etc. (as indicated in the FormatException docs) and this question applies to all of them.
How do I determine which string caused the FormatException?
I feel like this should be a parameter in the FormatException class, but if there is any way at all to get at it, I'd like to know. I was debugging deep in Microsoft's Deserialization code and ran against a brick wall when it wouldn't Step-Into further (not that this sledgehammer approach would have been elegant, even if it had worked).
Note: this is not a case for DateTime.ParseExact, as I don't know what format the string will be in, nor is it even a question about parsing dates, but it is a question about the exception itself and how to get more useful information out of it.