From 46b05977c84aca46559493dc8a2c00a8e2d31c1f Mon Sep 17 00:00:00 2001
From: Joscha Schmiedt <joscha@schmiedt.dev>
Date: Wed, 26 Mar 2025 17:22:18 +0100
Subject: [PATCH] Add handling of SSS server messages in gRPC

---
 .../grpc/ServerSideScriptingServiceImpl.java  | 40 +++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/caosdb/server/grpc/ServerSideScriptingServiceImpl.java b/src/main/java/org/caosdb/server/grpc/ServerSideScriptingServiceImpl.java
index b42dce48..99ed6a29 100644
--- a/src/main/java/org/caosdb/server/grpc/ServerSideScriptingServiceImpl.java
+++ b/src/main/java/org/caosdb/server/grpc/ServerSideScriptingServiceImpl.java
@@ -240,9 +240,43 @@ public class ServerSideScriptingServiceImpl extends ServerSideScriptingServiceIm
           new StatusException(Status.NOT_FOUND.withDescription(description).withCause(e)));
       return;
     }
-    // TODO: SERVER_SIDE_DOES_NOT_EXIST, SERVER_SIDE_SCRIPT_NOT_EXECUTABLE,
-    // SERVER_SIDE_SCRIPT_ERROR, SERVER_SIDE_SCRIPT_SETUP_ERROR,
-    // SERVER_SIDE_SCRIPT_TIMEOUT, SERVER_SIDE_SCRIPT_MISSING_CALL
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_DOES_NOT_EXIST)
+    {
+      responseObserver.onError(
+          new StatusException(Status.NOT_FOUND.withDescription(description).withCause(e)));
+      return;
+    }
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_NOT_EXECUTABLE)
+    {
+      responseObserver.onError(
+          new StatusException(Status.PERMISSION_DENIED.withDescription(description).withCause(e)));
+      return;
+    }
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_ERROR)
+    {
+      responseObserver.onError(
+          new StatusException(Status.UNKNOWN.withDescription(description).withCause(e)));
+      return;
+    }
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_SETUP_ERROR)
+    {
+      responseObserver.onError(
+          new StatusException(Status.UNKNOWN.withDescription(description).withCause(e)));
+      return;
+    }
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_TIMEOUT)
+    {
+      responseObserver.onError(
+          new StatusException(Status.DEADLINE_EXCEEDED.withDescription(description).withCause(e)));
+      return;
+    }
+    else if (e == ServerMessages.SERVER_SIDE_SCRIPT_MISSING_CALL)
+    {
+      responseObserver.onError(
+          new StatusException(Status.INVALID_ARGUMENT.withDescription(description).withCause(e)));
+      return;
+    }
+    
     e.printStackTrace();
     responseObserver.onError(
         new StatusException(Status.UNKNOWN.withDescription(description).withCause(e)));
-- 
GitLab