QuinnDamerell / Baconit

A beatiful, powerful, reddit client for Windows 10.
https://www.reddit.com/r/BaconitDev/
GNU General Public License v2.0
242 stars 81 forks source link

Community rules JSON parsing causes some subreddits to not be loaded. #51

Closed eugeniopacceli closed 8 years ago

eugeniopacceli commented 8 years ago

When attempting to access some subreddits, such as /r/relationships, the user is unable to load the subreddit thought baconit and a message of "not found" is shown, but the subreddit exists and is online.

The error happens in public async Task GetSubredditFromWebByDisplayName(string displayName) at BaconBackend.Managers.SubredditManager, line 195.

foundSubreddit = await Task.Run(() => JsonConvert.DeserializeObject(subredditData)); throws

"An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code

Additional information: Unexpected end when deserializing object. Path 'community_rules[0]', line 1, position 12303.

If there is a handler for this exception, the program may be safely continued."

This exception makes this message appear to the user:

"Hmmm, That's Not Right We can't load this subreddit right now, check your Internet connection." and the subreddit related is not loaded.

and the subreddit is not loaded.

Exemple: /r/relationships

Both in Visual Studio deployment and in a Lumia 640XL running Windows 10 beta.

eugeniopacceli commented 8 years ago

The json received from /r/relationships is valid.

https://www.reddit.com/r/relationships/about/.json

QuinnDamerell commented 8 years ago

Great catch and fix! Thanks so much!