Elepover / pmcenter

A Telegram bot helping you process private messages.
https://pmcenter.itsmy.app
Apache License 2.0
145 stars 34 forks source link

/switchlangcode unhandle at error #17

Closed tasi788 closed 4 years ago

tasi788 commented 5 years ago

Describe the bug /switchlangcode doesn't handle error when it can't read/find locale file.

To Reproduce Steps to reproduce the behavior:

  1. input /switchlangcode zh_tw to pmcenter bot (or something else)

Expected behavior when the locale file not found or other cause abort, it should reply something to make user know something went wrong.

Logs

2019-09-03T00:52:50.877061329Z [09/03/2019 00:52][BOT][ERROR] General error while processing incoming update: System.ArgumentException: Language not found.
2019-09-03T00:52:50.877201663Z    at pmcenter.Commands.SwitchLangCodeCommand.ExecuteAsync(TelegramBotClient botClient, Update update)
2019-09-03T00:52:50.877213716Z    at pmcenter.CommandManager.Execute(TelegramBotClient botClient, Update update) in C:\projects\pmcenter\pmcenter\CommandManager.cs:line 71
2019-09-03T00:52:50.877228261Z    at pmcenter.BotProcess.OwnerCommand(Update update) in C:\projects\pmcenter\pmcenter\BotProcess.cs:line 279
2019-09-03T00:52:50.877233542Z    at pmcenter.BotProcess.OwnerLogic(Update update) in C:\projects\pmcenter\pmcenter\BotProcess.cs:line 271
2019-09-03T00:52:50.877238653Z    at pmcenter.BotProcess.OnUpdate(Object sender, UpdateEventArgs e) in C:\projects\pmcenter\pmcenter\BotProcess.cs:line 88
Elepover commented 5 years ago

Did the bot send any message to the user when the error occurs? It should be:

✖ Error processing request: Language not found

It means that the specified language code couldn't be found in the locale map.

/switchlangcode command downloads the locale_map.json and then finds the corresponding language file. If no matching language code found, such error would be thrown.

tasi788 commented 5 years ago

I've tested several command, seems only /switchlangcode can't handle the error.

Version

Screenshot image

Elepover commented 4 years ago

Closing the issue for inability to reproduce. Feel free to open again if anything new is found.