aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/projectresolver.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-10-25 18:06:29 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-10-26 12:32:41 +0000
commit32c920a1db3da8e8ac627c627c8654dbd5f46e07 (patch)
tree8b3b19bece3cb1a6b4f094ec801107acf189905c /src/lib/corelib/language/projectresolver.cpp
parent98d6cddb6873de8be9149c370ef31a83fbdf13ce (diff)
Always mention the affected product for errors during project resolving
This is particularly useful for errors that occur when evaluating module properties, as the location where the error occurs usually gives no hint as to which product is involved. Change-Id: I92e5e23064c5d82f114d0144c41064276fd0491d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/language/projectresolver.cpp')
-rw-r--r--src/lib/corelib/language/projectresolver.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 4df39c697..c8bffd547 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -163,16 +163,8 @@ TopLevelProjectPtr ProjectResolver::resolve()
for (auto it = m_loadResult.productInfos.cbegin(); it != m_loadResult.productInfos.cend();
++it) {
const auto &productInfo = it.value();
- if (productInfo.delayedError.hasError()) {
- try {
- QString name = m_evaluator->stringValue(it.key(), QStringLiteral("name"));
- e.append(Tr::tr("Errors in product '%1':").arg(name), it.key()->location());
- } catch (const ErrorInfo &/* ignore */) {
- // The name cannot be determined because of other errors.
- e.append(Tr::tr("Errors in product:"), it.key()->location());
- }
+ if (productInfo.delayedError.hasError())
appendError(e, productInfo.delayedError);
- }
}
appendError(e, errorInfo);
throw e;
@@ -404,15 +396,19 @@ void ProjectResolver::resolveProduct(Item *item, ProjectContext *projectContext)
ProductContextSwitcher contextSwitcher(this, &productContext, m_progressObserver);
try {
resolveProductFully(item, projectContext);
- } catch (const ErrorInfo &error) {
+ } catch (const ErrorInfo &e) {
+ QString mainErrorString = !product->name.isEmpty()
+ ? Tr::tr("Error while handling product '%1':").arg(product->name)
+ : Tr::tr("Error while handling product:");
+ ErrorInfo fullError(mainErrorString, item->location());
+ appendError(fullError, e);
if (!product->enabled) {
- qCDebug(lcProjectResolver) << "error resolving product" << product->location
- << error.toString();
+ qCDebug(lcProjectResolver) << fullError.toString();
return;
}
if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict)
- throw;
- m_logger.printWarning(error);
+ throw fullError;
+ m_logger.printWarning(fullError);
m_logger.printWarning(ErrorInfo(Tr::tr("Product '%1' had errors and was disabled.")
.arg(product->name), item->location()));
product->enabled = false;
@@ -438,7 +434,13 @@ void ProjectResolver::resolveProductFully(Item *item, ProjectContext *projectCon
ModuleLoaderResult::ProductInfo &pi = m_loadResult.productInfos[item];
if (pi.delayedError.hasError()) {
ErrorInfo errorInfo;
- std::swap(pi.delayedError, errorInfo);
+
+ // First item is "main error", gets prepended again in the catch clause.
+ const QList<ErrorItem> &items = pi.delayedError.items();
+ for (int i = 1; i < items.count(); ++i)
+ errorInfo.append(items.at(i));
+
+ pi.delayedError.clear();
throw errorInfo;
}
gatherProductTypes(product.get(), item);