Search in sources :

Example 1 with ValidationLogDecorator

use of org.kie.kogito.process.validation.ValidationLogDecorator in project kogito-runtimes by kiegroup.

the class ProcessCodegen method handleValidation.

private static void handleValidation() {
    ValidationContext validationContext = ValidationContext.get();
    if (validationContext.hasErrors()) {
        // we may provide different validation decorators, for now just in logging in the console
        ValidationLogDecorator decorator = ValidationLogDecorator.of(validationContext).decorate();
        Optional<Exception> cause = validationContext.exception();
        // rethrow exception to break the flow after decoration
        try {
            throw new ProcessCodegenException(decorator.simpleMessage(), cause);
        } finally {
            validationContext.clear();
        }
    }
}
Also used : ValidationLogDecorator(org.kie.kogito.process.validation.ValidationLogDecorator) SAXException(org.xml.sax.SAXException) ValidationException(org.kie.kogito.process.validation.ValidationException) IOException(java.io.IOException) ValidationContext(org.kie.kogito.process.validation.ValidationContext)

Aggregations

IOException (java.io.IOException)1 ValidationContext (org.kie.kogito.process.validation.ValidationContext)1 ValidationException (org.kie.kogito.process.validation.ValidationException)1 ValidationLogDecorator (org.kie.kogito.process.validation.ValidationLogDecorator)1 SAXException (org.xml.sax.SAXException)1