Search in sources :

Example 1 with JsonErrorCodeDescription

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);
    }
}
Also used : JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription) ErrorCode(org.talend.daikon.exception.error.ErrorCode)

Example 2 with JsonErrorCodeDescription

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);
    }
}
Also used : JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription)

Aggregations

JsonErrorCodeDescription (org.talend.dataprep.exception.json.JsonErrorCodeDescription)2 ErrorCode (org.talend.daikon.exception.error.ErrorCode)1