public ValidationException getException ( ) { StringBuilder exceptionMessage = new StringBuilder ( ) ; for ( Problem problem : problems ) { exceptionMessage . append ( String . format ( "\n%s: %s" , problem . getContext ( ) . getPath ( ) , problem . getMessage ( ) ) ) ; } return new ValidationException ( exceptionMessage . toString ( ) ) ; }
Factory method to create an exception with all problems identified in the message .