CmdBridge: Improve error handling

The message result type was checked, but the promise
was still finished without an error.

Change-Id: Ib5ba5f48202073a82bfbcb871e0d5a5277ea9f2a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-07-11 07:02:43 +02:00
parent 580e2c379a
commit 15c5337649

View File

@@ -21,8 +21,13 @@
Q_LOGGING_CATEGORY(clientLog, "qtc.cmdbridge.client", QtWarningMsg)
#define ASSERT_TYPE(expectedtype) \
QTC_ASSERT(map.value("Type").toString() == expectedtype, promise.finish(); \
return JobResult::Done)
if (map.value("Type").toString() != expectedtype) { \
const QString err = QString("Unexpected result type: %1, expected: %2") \
.arg(map.value("Type").toString(), expectedtype); \
promise.setException(std::make_exception_ptr(std::runtime_error(err.toStdString()))); \
promise.finish(); \
return JobResult::Done; \
}
using namespace Utils;