summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-04-29 18:05:54 +0200
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-05-02 09:39:41 +0000
commit51d6717b4da23b85cbfbca3abf7bc492c1abe4ba (patch)
treef810f1fb25c96144f78941b1ad9025457f2ab49e
parentc400f70aa758673d158a7ef09ccaa88391ce6b9e (diff)
downloadqbs-51d6717b4da23b85cbfbca3abf7bc492c1abe4ba.tar.gz
Fix error locations
Read the content of the Error object, if there is one. Otherwise try to guess the location based on the value we just evaluated. Task-number: QBS-390 Change-Id: If1ac2a08e2d04b529656b3223ee22fe4e8895bee Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
-rw-r--r--src/lib/corelib/language/evaluator.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/lib/corelib/language/evaluator.cpp b/src/lib/corelib/language/evaluator.cpp
index eedb6e497..46b644bed 100644
--- a/src/lib/corelib/language/evaluator.cpp
+++ b/src/lib/corelib/language/evaluator.cpp
@@ -178,13 +178,31 @@ void Evaluator::handleEvaluationError(const Item *item, const QString &name,
{
if (Q_LIKELY(!m_scriptEngine->hasErrorOrException(scriptValue)))
return;
- const ValueConstPtr value = item->property(name);
- CodeLocation location = value ? value->location() : CodeLocation();
- if (m_scriptEngine->hasUncaughtException()) {
- throw ErrorInfo(m_scriptEngine->uncaughtException().toString(),
- CodeLocation(location.filePath(), m_scriptEngine->uncaughtExceptionLineNumber()));
+ QString message;
+ QString filePath;
+ int line = -1;
+ const QScriptValue value = scriptValue.isError() ? scriptValue
+ : m_scriptEngine->uncaughtException();
+ if (value.isError()) {
+ QScriptValue v = value.property(QStringLiteral("message"));
+ if (v.isString())
+ message = v.toString();
+ v = value.property(QStringLiteral("fileName"));
+ if (v.isString())
+ filePath = v.toString();
+ v = value.property(QStringLiteral("lineNumber"));
+ if (v.isNumber())
+ line = v.toInt32();
+ } else {
+ message = value.toString();
+ const ValueConstPtr value = item->property(name);
+ if (value) {
+ const CodeLocation location = value->location();
+ filePath = location.filePath();
+ line = location.line();
+ }
}
- throw ErrorInfo(scriptValue.toString(), location);
+ throw ErrorInfo(message, CodeLocation(filePath, line, -1, false));
}
bool Evaluator::evaluateProperty(QScriptValue *result, const Item *item, const QString &name,