]> nmode's Git Repositories - signal-cli/commitdiff
Improve error message and log output for failed jsonrpc commands
authorAsamK <asamk@gmx.de>
Sun, 8 Sep 2024 06:30:31 +0000 (08:30 +0200)
committerAsamK <asamk@gmx.de>
Sun, 8 Sep 2024 06:30:31 +0000 (08:30 +0200)
src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcCommandHandler.java

index 3609163c427777215748cf2a4e9e0294a0037631..96456a4edda31b2585d84fd87825e867a36d25e2 100644 (file)
@@ -229,15 +229,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)));
         }