PDA

View Full Version : QSA exceptions



seneca
2nd February 2006, 08:53
When a qsa script calls a qt method, is it possible for the c++ method to throw an excepion which then can be catched by the script?

example:


// QSA Script
try {
...
Application.object.property = 10;
...
}
catch ( e ) {
if (e = "some error") {
// do somesthing
} else {
// do something else
}
}



// qt method
MyObject::setProperty(int value)
{
...
if (value > 2) throw QString("some error");
...
}

e8johan
2nd February 2006, 15:53
I don't think that QSA supports exceptions at all. And Qt, in general, does not make use of C++ exceptions.

seneca
2nd February 2006, 16:27
QSA supports exceptions, and they can be detected in Qt by the QSInterpreter::hasError and errorMessage methods. There also are methods as QSInterpreter::throwError to throw an exception from Qt into QSA.

However what I am looking for is a way to throw an error within a Qt method, where I dont know if it was called by a script or c++. So there should at least exist a way to detect within script that a called C++ method has thrown an exception. But maybe it needs QSA wrappers for every Qt class which catch the C++ exception and then do a QSInterpreter::throwError. :confused: