aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/transformer.cpp
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@theqtcompany.com>2016-03-23 17:37:49 -0700
committerJake Petroules <jake.petroules@qt.io>2016-04-14 12:35:48 +0000
commit9eac02487ef5b8c94b08901b223b1d572642a68a (patch)
treeba51229d5779943841a697ede699d9b6617f709d /src/lib/corelib/buildgraph/transformer.cpp
parenta235900a7368fd2edf269454016c7577cb674323 (diff)
Display proper file paths and line numbers for errors in more places.
Rule.outputArtifacts, Rule.prepare, and Artifact.filePath will now display the correct file paths and line numbers for errors thrown from those locations (including in imported JavaScript files). Change-Id: I4e3c8e60f30791f5aa4de9e3813d4890c46c09fb Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/buildgraph/transformer.cpp')
-rw-r--r--src/lib/corelib/buildgraph/transformer.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp
index c0ad6ed07..9278df64d 100644
--- a/src/lib/corelib/buildgraph/transformer.cpp
+++ b/src/lib/corelib/buildgraph/transformer.cpp
@@ -208,7 +208,9 @@ void Transformer::createCommands(const ScriptFunctionConstPtr &script,
{
ScriptEngine * const engine = evalContext->engine();
if (!script->scriptFunction.isValid() || script->scriptFunction.engine() != engine) {
- script->scriptFunction = engine->evaluate(script->sourceCode);
+ script->scriptFunction = engine->evaluate(script->sourceCode,
+ script->location.filePath(),
+ script->location.line());
if (Q_UNLIKELY(!script->scriptFunction.isFunction()))
throw ErrorInfo(Tr::tr("Invalid prepare script."), script->location);
}
@@ -217,11 +219,15 @@ void Transformer::createCommands(const ScriptFunctionConstPtr &script,
propertiesRequestedInPrepareScript = engine->propertiesRequestedInScript();
propertiesRequestedFromArtifactInPrepareScript = engine->propertiesRequestedFromArtifact();
engine->clearRequestedProperties();
- if (Q_UNLIKELY(engine->hasErrorOrException(scriptValue)))
- throw ErrorInfo(Tr::tr("evaluating prepare script: ")
- + engine->lastErrorString(scriptValue),
- CodeLocation(script->location.filePath(),
- script->location.line() + engine->uncaughtExceptionLineNumber() - 1));
+ if (Q_UNLIKELY(engine->hasErrorOrException(scriptValue))) {
+ ErrorInfo errorInfo(engine->lastErrorString(scriptValue),
+ engine->uncaughtExceptionBacktraceOrEmpty());
+ if (rule)
+ errorInfo.append(QStringLiteral("Rule.prepare"), script->location);
+ else
+ errorInfo.append(QStringLiteral("Transformer.prepare"), script->location);
+ throw errorInfo;
+ }
commands.clear();
if (scriptValue.isArray()) {