Search in sources :

Example 1 with YamlProcessingException

use of com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException in project concord by walmartlabs.

the class YamlParserV2 method buildErrorMessage.

private static String buildErrorMessage(String fileName, YamlProcessingException e) {
    String prefix = "(" + fileName + "): Error";
    List<YamlProcessingException> errors = getYamlProcessingExceptionList(e);
    Collections.reverse(errors);
    String padding = "\t";
    StringBuilder result = new StringBuilder(toMessage(prefix, errors.remove(0)));
    List<InvalidFieldDefinitionException> stepErrors = errors.stream().filter(err -> err instanceof InvalidFieldDefinitionException).map(err -> (InvalidFieldDefinitionException) err).collect(Collectors.toList());
    if (stepErrors.size() > 0) {
        result.append("\n\t").append("while processing steps:");
    }
    for (InvalidFieldDefinitionException err : stepErrors) {
        result.append("\n").append(padding).append("'").append(err.getFieldName()).append("'").append(" @ ").append(Location.toShortString(err.getLocation()));
        padding += "\t";
    }
    return result.toString();
}
Also used : JsonLocation(com.fasterxml.jackson.core.JsonLocation) ProcessDefinition(com.walmartlabs.concord.runtime.v2.model.ProcessDefinition) JsonParser(com.fasterxml.jackson.core.JsonParser) InvalidFieldDefinitionException(com.walmartlabs.concord.runtime.v2.exception.InvalidFieldDefinitionException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) YamlProcessingException(com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException) Collectors(java.util.stream.Collectors) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ArrayList(java.util.ArrayList) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) List(java.util.List) YamlParserException(com.walmartlabs.concord.runtime.v2.exception.YamlParserException) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) Location(com.walmartlabs.concord.runtime.v2.model.Location) Path(java.nio.file.Path) Collections(java.util.Collections) YamlProcessingException(com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException) InvalidFieldDefinitionException(com.walmartlabs.concord.runtime.v2.exception.InvalidFieldDefinitionException)

Example 2 with YamlProcessingException

use of com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException in project concord by walmartlabs.

the class YamlDeserializersV2 method toException.

private static YamlProcessingException toException(Result.Failure<Atom, ?> f, JsonParser p, List<Atom> atoms) {
    Location loc = null;
    String got = "n/a";
    int pos = f.getPosition();
    if (pos >= 0) {
        Atom a = atoms.get(f.getPosition());
        loc = a.location;
        got = a.name;
    }
    return new YamlProcessingException(loc, "Expected: " + f.getMessage() + ". Got '" + got + "'");
}
Also used : YamlProcessingException(com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException) Location(com.walmartlabs.concord.runtime.v2.model.Location)

Aggregations

YamlProcessingException (com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException)2 Location (com.walmartlabs.concord.runtime.v2.model.Location)2 JsonLocation (com.fasterxml.jackson.core.JsonLocation)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 InvalidFieldDefinitionException (com.walmartlabs.concord.runtime.v2.exception.InvalidFieldDefinitionException)1 YamlParserException (com.walmartlabs.concord.runtime.v2.exception.YamlParserException)1 ProcessDefinition (com.walmartlabs.concord.runtime.v2.model.ProcessDefinition)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1