added handler on internal server error

This commit is contained in:
leca 2024-12-09 17:34:36 +03:00
parent baa8ae6e65
commit 22922aecaa
6 changed files with 47 additions and 18 deletions

View File

@ -1,4 +1,4 @@
-->[Русская версия](https://git.foxarmy.org/leca/checks-parser/src/branch/master/README.ru.md)<-->
-->[Русская версия](https://git.foxarmy.org/leca/checks-parser/src/branch/master/README.ru.md)<--
# Checks parser
checks parser is a program that help parsing different checks to csv.

View File

@ -1,4 +1,4 @@
-->[English version](https://git.foxarmy.org/leca/checks-parser/src/branch/master/README.md)<-->
-->[English version](https://git.foxarmy.org/leca/checks-parser/src/branch/master/README.md)<--
# Чек парсер
Чек парсер - это приложение, позволяющее доставать содержимое чека и переводить его в .csv файлы.

View File

@ -87,6 +87,13 @@ void MainWindow::on_parseButton_clicked() {
infoDialog.setWindowTitle(tr("Captcha is incorrect"));
infoDialog.exec();
break;
} else if (!strcmp(e.what(), "Internal server error")) {
QMessageBox infoDialog;
infoDialog.setText(tr("Internal server error. Please, try again later."));
infoDialog.setIcon(QMessageBox::Critical);
infoDialog.setWindowTitle(tr("Internal server error"));
infoDialog.exec();
return;
} else if (!strcmp(e.what(), "Does not exist")) {
QMessageBox infoDialog;
infoDialog.setText(tr("Check not found. Please, ensure correctness of entered data."));

View File

@ -118,7 +118,7 @@
<location filename="../mainwindow.ui" line="333"/>
<source>Funds income</source>
<translatorcomment>Приход средств</translatorcomment>
<translation>Funds incode</translation>
<translation>Funds income</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="338"/>
@ -160,37 +160,47 @@
</message>
<message>
<location filename="../mainwindow.cpp" line="92"/>
<source>Internal server error. Please, try again later.</source>
<translation>Internal server error. Please, try again later.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="94"/>
<source>Internal server error</source>
<translation>Internal server error</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="99"/>
<source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Check not found. Please, ensure correctness of entered data.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="94"/>
<location filename="../mainwindow.cpp" line="101"/>
<source>Check was not found</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<location filename="../mainwindow.cpp" line="123"/>
<source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source>
<translation>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="118"/>
<location filename="../mainwindow.cpp" line="125"/>
<source>Error in parsing</source>
<translation>Error in parsing</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="149"/>
<location filename="../mainwindow.cpp" line="156"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Please, select a picture where QR code that contains info about check is present</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="151"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../mainwindow.cpp" line="158"/>
<location filename="../mainwindow.cpp" line="204"/>
<source>Picture was not selected</source>
<translation>Picture was not selected</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="195"/>
<location filename="../mainwindow.cpp" line="202"/>
<source>Please, select a picture to scan</source>
<translation>Please, select a picture to scan</translation>
</message>

View File

@ -60,7 +60,7 @@
<location filename="../mainwindow.ui" line="108"/>
<source>OCR</source>
<translatorcomment>Оптическое Распознавание Символов</translatorcomment>
<translation type="unfinished">ОРС</translation>
<translation>ОРС</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="120"/>
@ -156,37 +156,47 @@
</message>
<message>
<location filename="../mainwindow.cpp" line="92"/>
<source>Internal server error. Please, try again later.</source>
<translation>Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="94"/>
<source>Internal server error</source>
<translation>Внутренняя ошибка сервера</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="99"/>
<source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="94"/>
<location filename="../mainwindow.cpp" line="101"/>
<source>Check was not found</source>
<translation>Чек не найден</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<location filename="../mainwindow.cpp" line="123"/>
<source>An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer.</source>
<translation>Произошла ошибка. Чек был прочитан неверно. Размеры векторов различаются. Пожалуйста, сообщите об этом разработчику.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="118"/>
<location filename="../mainwindow.cpp" line="125"/>
<source>Error in parsing</source>
<translation>Ошибка в парсинге</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="149"/>
<location filename="../mainwindow.cpp" line="156"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="151"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../mainwindow.cpp" line="158"/>
<location filename="../mainwindow.cpp" line="204"/>
<source>Picture was not selected</source>
<translation>Изображение не было выбрано</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="195"/>
<location filename="../mainwindow.cpp" line="202"/>
<source>Please, select a picture to scan</source>
<translation>Пожалуйста, выберете изображение для сканирования</translation>
</message>

View File

@ -124,6 +124,8 @@ Check parseOfdRuAnswer(std::string html) {
if ((products.size() + amounts.size() + prices.size()) == 0) {
if (html == "Bad Request4") { // Failed to solve a captcha
throw OfdRequestException("Incorrect captcha");
} else if (html.find("500 - Internal server error.") != std::string::npos) {
throw OfdRequestException("Internal server error");
} else { // Most likely that the check does not exist
throw OfdRequestException("Does not exist");
}