use of org.talend.dataprep.exception.json.JsonErrorCodeDescription in project data-prep by Talend.
the class CommonAPI method writeErrorsFromEnum.
/**
* Write the given error codes to the generator.
*
* @param generator the json generator to use.
* @param codes the error codes to write.
* @throws IOException if an error occurs.
*/
private void writeErrorsFromEnum(JsonGenerator generator, ErrorCode[] codes) throws IOException {
for (ErrorCode code : codes) {
// cast to JsonErrorCode needed to ease json handling
JsonErrorCodeDescription description = new JsonErrorCodeDescription(code);
generator.writeObject(description);
}
}
use of org.talend.dataprep.exception.json.JsonErrorCodeDescription in project data-prep by Talend.
the class CommonAPI method writeErrorsFromApi.
/**
* Write the given error codes to the generator.
*
* @param generator the json generator to use.
* @param input the error codes to write to read from the input stream.
* @throws IOException if an error occurs.
*/
private void writeErrorsFromApi(JsonGenerator generator, InputStream input) throws IOException {
Iterator<JsonErrorCodeDescription> iterator = mapper.readerFor(JsonErrorCodeDescription.class).readValues(input);
while (iterator.hasNext()) {
final JsonErrorCodeDescription description = iterator.next();
generator.writeObject(description);
}
}
Aggregations