aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-22 15:04:42 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-22 15:32:19 +0200
commit07782f48f4318a7261f1b0ddcd686b19ec812e36 (patch)
tree3fa2aa3a1170ad7ebaf5b1641cdce19a941ca480 /src/qml/jsapi
parent50fcdfd705c2ad9560641986bf4152b017ee8bb6 (diff)
parentf15a90e5d10465e66698209a5d88f1e63ae336fa (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/qml/qml/qqmlbinding.cpp src/qml/jsruntime/qv4arraybuffer.cpp src/qml/jsruntime/qv4functionobject.cpp Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r--src/qml/jsapi/qjsengine.cpp28
-rw-r--r--src/qml/jsapi/qjsvalue.cpp2
2 files changed, 21 insertions, 9 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index ceeaef1789..4db73c49f6 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -103,8 +103,8 @@ Q_DECLARE_METATYPE(QList<int>)
Here we pass the name of the file as the second argument to
evaluate(). This does not affect evaluation in any way; the second
- argument is a general-purpose string that is used to identify the
- script for debugging purposes.
+ argument is a general-purpose string that is stored in the \c Error
+ object for debugging purposes.
\section1 Engine Configuration
@@ -125,11 +125,21 @@ Q_DECLARE_METATYPE(QList<int>)
\section1 Script Exceptions
evaluate() can throw a script exception (e.g. due to a syntax
- error); in that case, the return value is the value that was thrown
- (typically an \c{Error} object). You can check whether the
- evaluation caused an exception by calling isError() on the return
- value. If isError() returns true, you can call toString() on the
- error object to obtain an error message.
+ error). If it does, then evaluate() returns the value that was thrown
+ (typically an \c{Error} object). Use \l QJSValue::isError() to check
+ for exceptions.
+
+ For detailed information about the error, use \l QJSValue::toString() to
+ obtain an error message, and use \l QJSValue::property() to query the
+ properties of the \c Error object. The following properties are available:
+
+ \list
+ \li \c name
+ \li \c message
+ \li \c fileName
+ \li \c lineNumber
+ \li \c stack
+ \endlist
\snippet code/src_script_qjsengine.cpp 4
@@ -282,7 +292,7 @@ void QJSEngine::installTranslatorFunctions(const QJSValue &object)
The script code will be evaluated in the context of the global object.
- The evaluation of \a program can cause an exception in the
+ The evaluation of \a program can cause an \l{Script Exceptions}{exception} in the
engine; in this case the return value will be the exception
that was thrown (typically an \c{Error} object; see
QJSValue::isError()).
@@ -372,7 +382,7 @@ QJSValue QJSEngine::newArray(uint length)
If the given \a object is deleted outside of the engine's control, any
attempt to access the deleted QObject's members through the JavaScript
wrapper object (either by script code or C++) will result in a
- script exception.
+ \l{Script Exceptions}{script exception}.
\sa QJSValue::toQObject()
*/
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index f6031d4268..466ac26eb6 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -310,6 +310,8 @@ bool QJSValue::isUndefined() const
/*!
Returns true if this QJSValue is an object of the Error class;
otherwise returns false.
+
+ \sa {QJSEngine#Script Exceptions}{QJSEngine - Script Exceptions}
*/
bool QJSValue::isError() const
{