public class SignalJsonRpcCommandHandler {
- private final static Logger logger = LoggerFactory.getLogger(SignalJsonRpcDispatcherHandler.class);
+ private static final Logger logger = LoggerFactory.getLogger(SignalJsonRpcDispatcherHandler.class);
private static final int USER_ERROR = -1;
private static final int IO_ERROR = -3;
}
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) {
if (manager == null) {
final var managers = c.getManagers();
if (managers.size() == 1) {
- manager = managers.get(0);
+ manager = managers.getFirst();
}
}
if (manager != null) {
}
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 -> {
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)));
}