]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcCommandHandler.java
Update libsignal-service-java
[signal-cli] / src / main / java / org / asamk / signal / jsonrpc / SignalJsonRpcCommandHandler.java
index 3609163c427777215748cf2a4e9e0294a0037631..48eb4a450390e2baaf5cc48663d0847044f3be1c 100644 (file)
@@ -56,7 +56,9 @@ public class SignalJsonRpcCommandHandler {
     }
 
     public JsonNode handleRequest(
-            final ObjectMapper objectMapper, final String method, ContainerNode<?> params
+            final ObjectMapper objectMapper,
+            final String method,
+            ContainerNode<?> params
     ) throws JsonRpcException {
         var command = getCommand(method);
         if (c != null) {
@@ -197,7 +199,9 @@ public class SignalJsonRpcCommandHandler {
     }
 
     private JsonNode runCommand(
-            final ObjectMapper objectMapper, final ContainerNode<?> params, final CommandRunner<?> command
+            final ObjectMapper objectMapper,
+            final ContainerNode<?> params,
+            final CommandRunner<?> command
     ) throws JsonRpcException {
         final Object[] result = {null};
         final JsonWriter commandJsonWriter = s -> {
@@ -229,15 +233,17 @@ public class SignalJsonRpcCommandHandler {
                 case RateLimitErrorException e -> throw new JsonRpcException(new JsonRpcResponse.Error(RATELIMIT_ERROR,
                         e.getMessage(),
                         getErrorDataNode(objectMapper, result)));
-                case UnexpectedErrorException e ->
-                        throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
-                                e.getMessage(),
-                                getErrorDataNode(objectMapper, result)));
+                case UnexpectedErrorException e -> {
+                    logger.error("Command execution failed with unexpected error", e);
+                    throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
+                            e.getMessage() + " (" + e.getClass().getSimpleName() + ")",
+                            getErrorDataNode(objectMapper, result)));
+                }
             }
         } catch (Throwable e) {
             logger.error("Command execution failed", e);
             throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
-                    e.getMessage(),
+                    e.getMessage() + " (" + e.getClass().getSimpleName() + ")",
                     getErrorDataNode(objectMapper, result)));
         }