nminaya / grammar-nazi-bot

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

Application Exception: Object reference not set to an instance of an object #56

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/13/2021 14:35:16

Exception:

System.NullReferenceException: Object reference not set to an instance of an object. at GrammarNazi.Core.Services.TelegramCommandHandlerService.HandleCommand(Message message) in /src/GrammarNazi.Core/Services/TelegramCommandHandlerService.cs:line 100 at GrammarNazi.App.HostedServices.TelegramBotHostedService.OnMessageReceived(Object sender, MessageEventArgs messageEvent) in /src/GrammarNazi.App/HostedServices/TelegramBotHostedService.cs:line 92 at GrammarNazi.App.HostedServices.TelegramBotHostedService.b__8_0(Object obj, MessageEventArgs eventArgs) in /src/GrammarNazi.App/HostedServices/TelegramBotHostedService.cs:line 72

nminaya commented 3 years ago

Same exception as issue #54

For now, we need to make sure this chatConfig variable is not null https://github.com/nminaya/grammar-nazi-bot/blob/56a9475a063de5f5df65aeadcf8bc23e16f388ec/GrammarNazi.Core/Services/TelegramCommandHandlerService.cs#L104

While investigating how that could be null at that point.

nminaya commented 3 years ago

Something similar to this issue happened in #63. The reason was, the bot was just added to a channel and received a settings command. So since there is not a ChannelConfiguration in the repository, the config variable was null.

Maybe that was what happened here. I'm going to fix this issue the same way #63 was fixed. Hoping this exception doesn't happen again.