static void renderError(JsonGenerator generator, ErrorMessage error) throws IOException {
        var summary = error.getMessage();
        var source = error.getSource();
        var cause = error.getCause();
        var message = error.getDetailedMessage();

        generator.writeStartObject();
        generator.writeNumberField(ERROR_CODE, error.getCode());
        generator.writeStringField(ERROR_SUMMARY, summary);

        if (source != null) {
            generator.writeStringField(ERROR_SOURCE, source);
        }

        if (message != null) {
            generator.writeStringField(ERROR_MESSAGE, message);
        }

        if (cause != null && shouldRenderStacktraceOf(cause) && cause.getStackTrace().length > 0) {
            var stringWriter = new StringWriter();
            var printWriter = new PrintWriter(stringWriter);
            cause.printStackTrace(printWriter);
            printWriter.close();
            generator.writeStringField(ERROR_STACK_TRACE, stringWriter.toString());
        }

        generator.writeEndObject();
    }
Creates a json renderer using a custom executor.
Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java