Improve error message and log output for failed jsonrpc commands

This commit is contained in:
AsamK 2024-09-08 08:30:31 +02:00
parent 485c4fd467
commit 7cc0ef1c70

View File

@ -229,15 +229,17 @@ public class SignalJsonRpcCommandHandler {
case RateLimitErrorException e -> throw new JsonRpcException(new JsonRpcResponse.Error(RATELIMIT_ERROR, case RateLimitErrorException e -> throw new JsonRpcException(new JsonRpcResponse.Error(RATELIMIT_ERROR,
e.getMessage(), e.getMessage(),
getErrorDataNode(objectMapper, result))); getErrorDataNode(objectMapper, result)));
case UnexpectedErrorException e -> case UnexpectedErrorException e -> {
throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR, logger.error("Command execution failed with unexpected error", e);
e.getMessage(), throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
getErrorDataNode(objectMapper, result))); e.getMessage() + " (" + e.getClass().getSimpleName() + ")",
getErrorDataNode(objectMapper, result)));
}
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Command execution failed", e); logger.error("Command execution failed", e);
throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR, throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
e.getMessage(), e.getMessage() + " (" + e.getClass().getSimpleName() + ")",
getErrorDataNode(objectMapper, result))); getErrorDataNode(objectMapper, result)));
} }