Add error handling to JSConsole

This commit is contained in:
Ryan Huffman 2015-05-14 11:00:30 -07:00
parent b658c26799
commit 0cd60782e7
2 changed files with 6 additions and 0 deletions

View file

@ -59,6 +59,7 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
connect(_scriptEngine, SIGNAL(evaluationFinished(QScriptValue, bool)),
this, SLOT(handleEvalutationFinished(QScriptValue, bool)));
connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(handlePrint(const QString&)));
connect(_scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(handleError(const QString&)));
resizeTextInput();
}
@ -96,6 +97,10 @@ void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException)
appendMessage(gutter, resultStr);
}
void JSConsole::handleError(const QString& message) {
appendMessage(GUTTER_ERROR, "<span style='" + RESULT_ERROR_STYLE + "'>" + message.toHtmlEscaped() + "</span>");
}
void JSConsole::handlePrint(const QString& message) {
appendMessage("", message);
}

View file

@ -49,6 +49,7 @@ protected slots:
void resizeTextInput();
void handleEvalutationFinished(QScriptValue result, bool isException);
void handlePrint(const QString& message);
void handleError(const QString& message);
private:
void appendMessage(const QString& gutter, const QString& message);