This is what I love about Delphi. After almost 15 years of Delphi’ing there’s still new things to learn, and I don’t just mean new features in the latest releases. I mean, basic, fundamental things that have been there for years, just undiscovered (by me).I fully agree, and today it was my turn to find such an "undiscovered (by me)" thing in Delphi.
I received a bugreport about a simple edit screen not opening due to an EVariantInvalidArgError exception. Strange, because the exception seemed to be in straightforward code that has been in production for twelve odd years, and hasn't been changed lately (sound familiar?).
// example user input from the edit screen
// store the date value when the edit screen closes
StoredValue := StrToDate(EditText);
// convert the stored value to string when the edit screen opens
EditText := VarToStr(StoredValue);
<= EVariantInvalidArgError reported ???
Not much too worry about codewise it seems. And I couldn't reproduce the error using my development data. Still, the error was readily reproducible in the production environment, so I looked at the production database record to see what value was causing the trouble. It turned out to be '01-01-0010'. Clearly a typo by a user that wanted to write '01-01-2010'. A typo maybe, but a valid date nevertheless. And besides, if there really was anything fishy about that date, I would expect the exception to be raised when trying to store the value in the variant, not when converting the variant back to a string. What was happening?
I realize I just love this part of my work. Admittedly, there have been bugs in the past that I loved a lot less. But this was one of the "feel good" bugs. A bug that is brought to your attention by strange, apparently unexplainable symptoms. A bug that takes some effort (but no longer than say a few hours) to localize (and is preferably localized in some else's code), and finally a bug that is easy to repair or workaround.
Can't wait for the next one.