package org.skyve.domain.messages;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 */
public class ValidationException extends DomainException implements MessageException {
	/**
	 * For Serialization
	 */
	private static final long serialVersionUID = -2033700648810378214L;

	protected List<Message> messages = new ArrayList<>();

	public ValidationException() {
	}
	
	/**
	 * 
	 * @param message
	 */
	public ValidationException(Message message) {
		messages.add(message);
	}

	@Override
	public List<Message> getMessages() {
		return messages;
	}

	@Override
	public String toString() {
		StringBuilder result = new StringBuilder(super.toString());
		for (Message message : messages) {
			result.append('\n').append(message.toString());
		}
		
		return result.toString();
	}

	@Override
	public String getMessage() {
		return toString();
	}
}

@@ -587,20 +587,66 @@
 ing 
-toString() %7B
+getMessage() %7B%0A%09%09String superMessage = super.getMessage();
 %0A%09%09S
@@ -689,24 +689,50 @@
 der(
+(
 super
-.toString()
+Message == null) ? %22%22 : superMessage
 );%0A%09
@@ -825,16 +825,16 @@
 %0A%09%09%7D%0A%09%09%0A
+
 %09%09return
@@ -859,73 +859,7 @@
 ;%0A%09%7D
-%0A%0A%09@Override%0A%09public String getMessage() %7B%0A%09%09return toString();%0A%09%7D
 %0A%7D%0A

Remove infinite recursive calls through Throwable involving ValidationException.toString() and ValidationException.getMessage().