static void closeSilently(
      final ServerWebSocket webSocket,
      final int code,
      final String message) {
    try {
      final ImmutableMap<String, String> finalMessage = ImmutableMap.of(
          "error",
          message != null ? message : ""
      );
      final String json = ApiJsonMapper.INSTANCE.get().writeValueAsString(finalMessage);
      webSocket
          .writeFinalTextFrame(json, r -> { })
          .close((short) code, truncate(message));
    } catch (final Exception e) {
      LOG.info("Exception caught closing websocket", e);
    }
  }
@Test
  public void shouldCloseQuietly() throws Exception {
    // Given:
    doThrow(new RuntimeException("Boom")).when(websocket)
        .close(any(Short.class), any(String.class));


    // When:
    SessionUtil.closeSilently(websocket, INVALID_MESSAGE_TYPE.code(), "reason");

    // Then:
    verify(websocket).close(any(Short.class), any(String.class));
    // And exception swallowed.
  }