src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py

branch
eric7
changeset 10953
42166c630d9b
parent 10767
b3672d3e7644
child 10954
c3d109783fbd
--- a/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py	Sat Oct 05 13:52:42 2024 +0200
+++ b/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py	Sat Oct 05 14:14:59 2024 +0200
@@ -52,6 +52,30 @@
 
         self.__originalPathString = os.getenv("PATH")
 
+    def sendError(self, request, reqestUuid="", errorMessage=None):
+        """
+        Public method to send an error report to the IDE.
+
+        @param request request name
+        @type str
+        @param reqestUuid UUID of the associated request as sent by the eric IDE
+            (defaults to "", i.e. no UUID received)
+        @type str
+        @param errorMessage error message to be sent back (defaults to None)
+        @type str (optional)
+        """
+        if errorMessage:
+            self._server.sendJson(
+                category=self._category,
+                reply=request,
+                params={
+                    "Error": f"Error during request type '{request}': {errorMessage}"
+                },
+                reqestUuid=reqestUuid,
+            )
+        else:
+            super().sendError(request=request, reqestUuid=reqestUuid)
+
     def initServerSocket(self):
         """
         Public method to initialize the server socket listening for debug client
@@ -281,13 +305,16 @@
         if self.__originalPathString:
             clientEnv["PATH"] = self.__originalPathString
 
-        self.__client = subprocess.Popen(
-            args,
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE,
-            cwd=workingDir,
-            env=clientEnv,
-        )
+        try:
+            self.__client = subprocess.Popen(
+                args,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.PIPE,
+                cwd=workingDir,
+                env=clientEnv,
+            )
+        except (OSError, ValueError, subprocess.SubprocessError) as err:
+            self.sendError(request="StartClient", errorMessage=str(err))
 
     def __stopClient(self, params):  # noqa: U100
         """

eric ide

mercurial