Improve error message when the executable path in the launcher is empty

* Show error "executable path is empty" instead of "Unknown error"
This commit is contained in:
Martchus 2023-01-12 22:39:47 +01:00
parent f04c482538
commit 268164748f
3 changed files with 13 additions and 1 deletions

View File

@ -203,6 +203,17 @@ QStringList SyncthingProcess::splitArguments(const QString &arguments)
return result;
}
/*!
* \brief Emits errorOccurred() as if the specified \a error had occurred and sets the specified \a errorString.
* \remarks May be called if a precondition for starting the process (that is checked outside of the SyncthingProcess
* class itself) has failed (instead of starting the process).
*/
void SyncthingProcess::reportError(QProcess::ProcessError error, const QString &errorString)
{
setErrorString(errorString);
emit errorOccurred(error);
}
/*!
* \brief Stops the currently running process gracefully. If it has been stopped, starts the specified \a program with the specified \a arguments.
* \sa See stopSyncthing() for details about \a currentConnection.

View File

@ -40,6 +40,7 @@ public:
static SyncthingProcess *mainInstance();
static void setMainInstance(SyncthingProcess *mainInstance);
static QStringList splitArguments(const QString &arguments);
void reportError(QProcess::ProcessError error, const QString &errorString);
#ifdef LIB_SYNCTHING_CONNECTOR_BOOST_PROCESS
QProcess::ProcessState state() const;
void start(const QString &program, const QStringList &arguments, QIODevice::OpenMode openMode = QIODevice::ReadOnly);

View File

@ -123,7 +123,7 @@ void SyncthingLauncher::launch(const Settings::Launcher &launcherSettings)
return;
}
if (!launcherSettings.useLibSyncthing && launcherSettings.syncthingPath.isEmpty()) {
emit errorOccurred(QProcess::FailedToStart);
m_process.reportError(QProcess::FailedToStart, QStringLiteral("executable path is empty"));
return;
}
if (launcherSettings.useLibSyncthing) {