private static void exportEvents(JShell shell, List<SnippetEvent> events, Response response) {
    for (SnippetEvent event : events) {
      final Snippet.Status status = event.status();
      final Snippet snippet = event.snippet();
      final Event e = new Event(
        createCodeSnippet(snippet),
        createCodeSnippet(event.causeSnippet()),
        convertEnum(status, CodeSnippet.Status.class),
        convertEnum(event.previousStatus(), CodeSnippet.Status.class),
        event.value()
      );
      final JShellException exception = event.exception();
      if (exception != null) {
        e.setExceptionText(exception.getMessage());
      }
      if (status == Snippet.Status.RECOVERABLE_DEFINED || status == Snippet.Status.RECOVERABLE_NOT_DEFINED || status == Snippet.Status.REJECTED) {
        final StringBuilder buf = new StringBuilder();
        shell.diagnostics(snippet).forEach(diagnostic -> {
          final String message = diagnostic.getMessage(Locale.US);
          if (message != null && !message.isEmpty()) {
            if (buf.length() > 0){
              buf.append("\n");
            }
            if (diagnostic.isError()) {
              buf.append("ERROR: ");
            }
            buf.append(message);
          }
        });
        if (buf.length() > 0) {
          e.setDiagnostic(buf.toString());
        }
      }
      response.addEvent(e);
    }
  }
private static void exportEvents(JShell shell, List<SnippetEvent> events, Response response)