Search in sources :

Example 6 with Problem

use of org.leadpony.justify.api.Problem in project devspaces-images by redhat-developer.

the class ErrorMessageComposer method extractMessages.

/**
 * Parses {@link Problem} list into an error string. Each problem is recursively parsed to extract
 * nested errors if any.
 *
 * @param validationErrors Schema validation problems list
 * @return composite error string
 */
public String extractMessages(List<Problem> validationErrors, StringBuilder messageBuilder) {
    for (Problem problem : validationErrors) {
        int branchCount = problem.countBranches();
        if (branchCount == 0) {
            messageBuilder.append(getMessage(problem));
        } else {
            messageBuilder.append(problem.getMessage()).append(": [");
            for (int i = 0; i < branchCount; i++) {
                extractMessages(problem.getBranch(i), messageBuilder);
            }
            messageBuilder.append("]");
        }
    }
    return messageBuilder.toString();
}
Also used : Problem(org.leadpony.justify.api.Problem)

Aggregations

Problem (org.leadpony.justify.api.Problem)6 ArrayList (java.util.ArrayList)4 ProblemHandler (org.leadpony.justify.api.ProblemHandler)4 JsonSchema (org.leadpony.justify.api.JsonSchema)3 JsonReader (jakarta.json.JsonReader)2 IOException (java.io.IOException)2 StringReader (java.io.StringReader)2 JsonException (javax.json.JsonException)2 JsonParsingException (javax.json.stream.JsonParsingException)2 DevfileException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileException)2 DevfileFormatException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException)2 JsonReader (javax.json.JsonReader)1 JsonParser (javax.json.stream.JsonParser)1