You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/07/10 16:40:15 UTC

(camel) 14/19: chore: return JSON-RPC error instead of bare 500 in TuiMcpServer exception handler

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a273e5cf32e87fc7a25b81121430a3170afc5492
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 10 18:03:02 2026 +0200

    chore: return JSON-RPC error instead of bare 500 in TuiMcpServer exception handler
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
    Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
 .../camel/dsl/jbang/core/commands/tui/TuiMcpServer.java     | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
index 82734e04457d..a4cca6563049 100644
--- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
+++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
@@ -190,7 +190,18 @@ class TuiMcpServer {
                 logMethodCall(jsonrpcMethod, request, body, responseJson);
             }
         } catch (Exception e) {
-            exchange.sendResponseHeaders(500, -1);
+            try {
+                JsonObject error = new JsonObject();
+                error.put("code", -32603);
+                error.put("message", "Internal error");
+                JsonObject response = new JsonObject();
+                response.put("jsonrpc", "2.0");
+                response.put("id", null);
+                response.put("error", error);
+                sendJson(exchange, 200, response);
+            } catch (Exception ignored) {
+                // headers already sent
+            }
         } finally {
             exchange.close();
         }