Commit 0a854708 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Return error messages

parent 73af59f4
Pipeline #55802 passed with stage
in 54 minutes and 53 seconds
......@@ -7,6 +7,7 @@
#include "grammalecteresultjob.h"
#include "libgrammalecte_debug.h"
#include <QFileInfo>
#include <QTemporaryFile>
GrammalecteResultJob::GrammalecteResultJob(QObject *parent)
......@@ -135,6 +136,14 @@ bool GrammalecteResultJob::canStart()
mErrorType = ErrorType::PythonPathMissing;
return false;
}
if (!QFileInfo::exists(mPythonPath)) {
mErrorType = ErrorType::PythonPathNotExist;
return false;
}
if (!QFileInfo::exists(mGrammarlecteCliPath)) {
mErrorType = ErrorType::GrammarlectCliNotExist;
return false;
}
return true;
}
......
......@@ -21,7 +21,9 @@ public:
TextIsEmpty = 1,
PythonPathMissing = 2,
GrammalecteMissing = 3,
Unknown = 4,
PythonPathNotExist = 4,
GrammarlectCliNotExist = 5,
Unknown = 6,
};
void start();
......
......@@ -9,6 +9,8 @@
#include "grammalecteparser.h"
#include "grammarresulttextedit.h"
#include "libgrammalecte_debug.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QJsonDocument>
GrammalecteResultWidget::GrammalecteResultWidget(QWidget *parent)
......@@ -42,6 +44,7 @@ void GrammalecteResultWidget::slotCheckGrammarFinished(const QString &result)
void GrammalecteResultWidget::slotError(GrammalecteResultJob::ErrorType error)
{
QString str;
switch (error) {
case GrammalecteResultJob::ErrorType::NoError:
break;
......@@ -50,12 +53,25 @@ void GrammalecteResultWidget::slotError(GrammalecteResultJob::ErrorType error)
break;
case GrammalecteResultJob::ErrorType::PythonPathMissing:
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "An error found during executing GrammalecteResultJob: missing python path";
str = i18n("Python path is missing.");
break;
case GrammalecteResultJob::ErrorType::GrammalecteMissing:
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "An error found during executing GrammalecteResultJob: missing grammalectepath";
str = i18n("Grammalecte path not found.");
break;
case GrammalecteResultJob::ErrorType::Unknown:
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "An error found during executing GrammalecteResultJob: unknow error";
break;
case GrammalecteResultJob::ErrorType::PythonPathNotExist:
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "An error found during executing GrammalecteResultJob: python exec doesn't exist";
str = i18n("Grammalecte program file not found.");
break;
case GrammalecteResultJob::ErrorType::GrammarlectCliNotExist:
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "An error found during executing GrammalecteResultJob: grammalecte cli not found.";
str = i18n("Grammalecte cli file not found.");
break;
}
if (!str.isEmpty()) {
KMessageBox::error(this, str, i18n("Grammalecte error"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment