public ObjectNode toRestconfErrorJson() {
        ObjectMapper mapper = new ObjectMapper();
        ArrayNode errorArray = mapper.createArrayNode();
        restconfErrors.forEach(error -> errorArray.add(error.toJson()));
        ObjectNode errorsNode = (ObjectNode) mapper.createObjectNode();
        errorsNode.put("ietf-restconf:errors", errorArray);
        return errorsNode;
    }
@Test
    public void testToRestconfErrorJson() {
        IllegalArgumentException ie = new IllegalArgumentException("This is a test");
        RestconfException e = new RestconfException("Error in system", ie,
                RestconfError.ErrorTag.DATA_EXISTS, Response.Status.BAD_REQUEST,
                Optional.of("/some/path"));
        e.addToErrors(error1);
        e.addToErrors(error2);
        e.addToErrors(error3);

        assertEquals("{\"ietf-restconf:errors\":[" +
                "{\"error\":{" +
                    "\"error-type\":\"application\"," +
                    "\"error-tag\":\"data-exists\"," +
                    "\"error-path\":\"/some/path\"," +
                    "\"error-message\":\"Error in system\"," +
                    "\"error-info\":\"This is a test\"}}," +
                "{\"error\":{" +
                    "\"error-type\":\"transport\"," +
                    "\"error-tag\":\"access-denied\"}}," +
                "{\"error\":{" +
                    "\"error-type\":\"transport\"," +
                    "\"error-tag\":\"bad-attribute\"}}," +
                "{\"error\":{" +
                    "\"error-type\":\"rpc\"," +
                    "\"error-tag\":\"bad-element\"," +
                    "\"error-app-tag\":\"my-app-tag\"," +
                    "\"error-path\":\"/a/b/c\"," +
                    "\"error-message\":\"a message about the error\"," +
                    "\"error-info\":\"info about the error\"}}]}",
                e.toRestconfErrorJson().toString());
    }