nminaya / grammar-nazi-bot

Bot that corrects spelling mistakes.
MIT License
31 stars 8 forks source link

Application Exception: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. #52

Closed nminaya closed 3 years ago

nminaya commented 3 years ago

This is an issue created automatically by GrammarNazi when an exception was captured.

Date (UTC): 01/09/2021 22:40:32

Exception:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at GrammarNazi.Core.Clients.LanguageToolApiClient.Check(String text, String languageCode) in /src/GrammarNazi.Core/Clients/LanguageToolApiClient.cs:line 28 at GrammarNazi.Core.Services.LanguageToolApiService.GetCorrections(String text) in /src/GrammarNazi.Core/Services/GrammarServices/LanguageToolApiService.cs:line 56 at GrammarNazi.App.HostedServices.TwitterBotHostedService.ExecuteAsync(CancellationToken stoppingToken) in /src/GrammarNazi.App/HostedServices/TwitterBotHostedService.cs:line 93

nminaya commented 3 years ago

Looks like there are some times when LanguageTool API returns an invalid JSON. We need to handle this scenario. The same exception was captured in #51