public static KustoServiceQueryError fromOneApiErrorArray()

in data/src/main/java/com/microsoft/azure/kusto/data/exceptions/KustoServiceQueryError.java [32:65]


    public static KustoServiceQueryError fromOneApiErrorArray(ArrayNode jsonExceptions, boolean isOneApi) {
        List<RuntimeException> exceptions = new ArrayList<>();
        StringBuilder sb = new StringBuilder();

        if (jsonExceptions == null || jsonExceptions.isEmpty()) {
            return new KustoServiceQueryError("No exceptions were returned from the service.");
        }

        if (jsonExceptions.size() > 1) {
            sb.append(EXCEPTIONS_MESSAGE);
        }

        for (int i = 0; i < jsonExceptions.size(); i++) {
            JsonNode jsonNode = jsonExceptions.get(i);
            String value = jsonNode.isTextual() ? jsonNode.asText() : jsonNode.toString();
            String message = value;
            RuntimeException exception;
            if (isOneApi) {
                DataWebException ex = new DataWebException(value);
                OneApiError apiError = ex.getApiError();
                if (apiError != null) {
                    message = apiError.getCode() + ": " + apiError.getMessage();
                }
                exception = ex;
            } else {
                exception = new RuntimeException(value);
            }
            exceptions.add(exception);
            sb.append(message);
            sb.append("\n");
        }

        return new KustoServiceQueryError(sb.toString(), exceptions);
    }