forked from qt-creator/qt-creator
Qbs: Better error messages
Provides more concrete error messages if the executable is not set or not executable. Change-Id: I336e9cd10ed6588d77add24af1fd0a9fc9766134 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -187,8 +187,12 @@ void QbsSession::initialize()
|
|||||||
connect(d->packetReader, &PacketReader::packetReceived, this, &QbsSession::handlePacket);
|
connect(d->packetReader, &PacketReader::packetReceived, this, &QbsSession::handlePacket);
|
||||||
d->state = State::Initializing;
|
d->state = State::Initializing;
|
||||||
const FilePath qbsExe = QbsSettings::qbsExecutableFilePath();
|
const FilePath qbsExe = QbsSettings::qbsExecutableFilePath();
|
||||||
if (qbsExe.isEmpty() || !qbsExe.exists()) {
|
if (qbsExe.isEmpty()) {
|
||||||
QTimer::singleShot(0, this, [this] { setError(Error::QbsFailedToStart); });
|
QTimer::singleShot(0, this, [this] { setError(Error::NoQbsPath); });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!qbsExe.isExecutableFile()) {
|
||||||
|
QTimer::singleShot(0, this, [this] { setError(Error::InvalidQbsExecutable); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->qbsProcess->setCommand({qbsExe, {"session"}});
|
d->qbsProcess->setCommand({qbsExe, {"session"}});
|
||||||
@@ -223,6 +227,12 @@ std::optional<QbsSession::Error> QbsSession::lastError() const
|
|||||||
QString QbsSession::errorString(QbsSession::Error error)
|
QString QbsSession::errorString(QbsSession::Error error)
|
||||||
{
|
{
|
||||||
switch (error) {
|
switch (error) {
|
||||||
|
case Error::NoQbsPath:
|
||||||
|
return Tr::tr("No qbs executable was found, please set the path in the settings.");
|
||||||
|
case Error::InvalidQbsExecutable:
|
||||||
|
return Tr::tr("The qbs executable was not found at the specified path, or it is not "
|
||||||
|
"executable (\"%1\").")
|
||||||
|
.arg(QbsSettings::qbsExecutableFilePath().toUserOutput());
|
||||||
case Error::QbsQuit:
|
case Error::QbsQuit:
|
||||||
return Tr::tr("The qbs process quit unexpectedly.");
|
return Tr::tr("The qbs process quit unexpectedly.");
|
||||||
case Error::QbsFailedToStart:
|
case Error::QbsFailedToStart:
|
||||||
@@ -231,7 +241,8 @@ QString QbsSession::errorString(QbsSession::Error error)
|
|||||||
return Tr::tr("The qbs process sent unexpected data.");
|
return Tr::tr("The qbs process sent unexpected data.");
|
||||||
case Error::VersionMismatch:
|
case Error::VersionMismatch:
|
||||||
return Tr::tr("The qbs API level is not compatible with "
|
return Tr::tr("The qbs API level is not compatible with "
|
||||||
"what %1 expects.").arg(Core::Constants::IDE_DISPLAY_NAME);
|
"what %1 expects.")
|
||||||
|
.arg(Core::Constants::IDE_DISPLAY_NAME);
|
||||||
}
|
}
|
||||||
return QString(); // For dumb compilers.
|
return QString(); // For dumb compilers.
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,14 @@ public:
|
|||||||
~QbsSession() override;
|
~QbsSession() override;
|
||||||
|
|
||||||
enum class State { Initializing, Active, Inactive };
|
enum class State { Initializing, Active, Inactive };
|
||||||
enum class Error { QbsFailedToStart, QbsQuit, ProtocolError, VersionMismatch };
|
enum class Error {
|
||||||
|
NoQbsPath,
|
||||||
|
InvalidQbsExecutable,
|
||||||
|
QbsFailedToStart,
|
||||||
|
QbsQuit,
|
||||||
|
ProtocolError,
|
||||||
|
VersionMismatch
|
||||||
|
};
|
||||||
|
|
||||||
std::optional<Error> lastError() const;
|
std::optional<Error> lastError() const;
|
||||||
static QString errorString(Error error);
|
static QString errorString(Error error);
|
||||||
|
Reference in New Issue
Block a user