lewishenson / FluentMetacritic

C# API for scraping Metacritic search results
MIT License
7 stars 1 forks source link

Need to handle "TBA" in the release date field #5

Closed SlyCaptainFlint closed 7 years ago

SlyCaptainFlint commented 7 years ago

I was trying to integrate the library into my new project, and noticing exceptions on specific game queries (try "The Witcher 3" or "Black Ops" for examples). I have investigated and found that the issue is that some results have "TBA" instead of a date listed in the "release date" field, which makes the Convert.ChangeType call fail. This throws a System.FormatException, which is not handled currently. I'm happy to fix the issue and add exception handling for this value to the SafeConvert method inside the Converter class, but wanted to see if there was a preference for the way this exception is handled. I would like to either return the default value of DateTime or null in case a "TBA" is encountered. Thoughts on either? LMK and I can put out a pull request

lewishenson commented 7 years ago

I would say return null - it's already a nullable DateTime field which is supposed to be null if there's not a date(time) value.

Give it a go, more than happy to take a contribution!