summaryrefslogtreecommitdiffstats
path: root/scriptrunner.cpp
diff options
context:
space:
mode:
authorJesper K. Pedersen <[email protected]>2013-04-17 14:52:52 +0200
committerJesper K. Pedersen <[email protected]>2013-04-17 20:50:44 +0200
commitcf9aee24f52704f70a5cb59e8cf15258d7e17445 (patch)
treead01aa7a3ca1d3bf25e844b061cd88678b4874a9 /scriptrunner.cpp
parent487770e422e4c55e128c210bb82b30ed99f3f401 (diff)
improved error handling
Change-Id: I3cd3632c17fb542cb0ab32a2ebebfc3c780aae22 Reviewed-by: Nicolas Arnaud-Cormos <[email protected]>
Diffstat (limited to 'scriptrunner.cpp')
-rw-r--r--scriptrunner.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/scriptrunner.cpp b/scriptrunner.cpp
index a02aaaf..5df00fc 100644
--- a/scriptrunner.cpp
+++ b/scriptrunner.cpp
@@ -59,12 +59,12 @@ ScriptRunner::~ScriptRunner()
}
-bool ScriptRunner::runScript(const QString &sourceCode, const QString fileName)
+ErrorMessage ScriptRunner::runScript(const QString &sourceCode, const QString fileName)
{
ensureEngineInitialized();
m_engine->pushContext();
- m_engine->evaluate(sourceCode, fileName);
+ QScriptValue result = m_engine->evaluate(sourceCode, fileName);
const bool failed = m_engine->hasUncaughtException();
m_engine->popContext();
@@ -74,7 +74,10 @@ bool ScriptRunner::runScript(const QString &sourceCode, const QString fileName)
if (editorManager->currentEditor())
editorManager->currentEditor()->widget()->setFocus(Qt::OtherFocusReason);
- return !failed;
+ if ( failed)
+ return ErrorMessage(m_engine->uncaughtExceptionLineNumber(), result.toString());
+
+ return ErrorMessage();
}