Web: handle system exit exceptions
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
@@ -129,21 +130,26 @@ private:
|
||||
throw Py::OverflowError("port number is lower than 0");
|
||||
}
|
||||
|
||||
AppServer server(true);
|
||||
if (server.listen(QHostAddress(QString::fromLatin1(addr)), port)) {
|
||||
bool ok = server.waitForNewConnection(timeout);
|
||||
QTcpSocket* socket = server.nextPendingConnection();
|
||||
if (socket) {
|
||||
socket->waitForReadyRead();
|
||||
}
|
||||
try {
|
||||
AppServer server(true);
|
||||
if (server.listen(QHostAddress(QString::fromLatin1(addr)), port)) {
|
||||
bool ok = server.waitForNewConnection(timeout);
|
||||
QTcpSocket* socket = server.nextPendingConnection();
|
||||
if (socket) {
|
||||
socket->waitForReadyRead();
|
||||
}
|
||||
|
||||
server.close();
|
||||
return Py::Boolean(ok);
|
||||
server.close();
|
||||
return Py::Boolean(ok);
|
||||
}
|
||||
else {
|
||||
std::stringstream out;
|
||||
out << "Server failed to listen at address " << addr << " and port " << port;
|
||||
throw Py::RuntimeError(out.str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::stringstream out;
|
||||
out << "Server failed to listen at address " << addr << " and port " << port;
|
||||
throw Py::RuntimeError(out.str());
|
||||
catch (const Base::SystemExitException& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -216,6 +216,9 @@ std::string AppServer::runPython(const QByteArray& msg)
|
||||
str += "\n\n";
|
||||
str += e.getStackTrace();
|
||||
}
|
||||
catch (Base::SystemExitException &) {
|
||||
throw;
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
str = e.what();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user