diff --git a/src/Mod/Web/App/AppWeb.cpp b/src/Mod/Web/App/AppWeb.cpp
index bfb4d892bc..8518801dd8 100644
--- a/src/Mod/Web/App/AppWeb.cpp
+++ b/src/Mod/Web/App/AppWeb.cpp
@@ -29,6 +29,7 @@
#endif
#include
+#include
#include
#include
@@ -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());
}
}
diff --git a/src/Mod/Web/App/Server.cpp b/src/Mod/Web/App/Server.cpp
index 41a980a85f..091c4a1480 100644
--- a/src/Mod/Web/App/Server.cpp
+++ b/src/Mod/Web/App/Server.cpp
@@ -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();
}