1

Implemented Exeption and their handling

This commit is contained in:
Mahgs
2020-03-09 16:18:14 +01:00
parent 72c8d2b9b0
commit b30a4d02f9
7 changed files with 73 additions and 15 deletions

View File

@ -1,10 +1,17 @@
package mops.gruppen2.domain;
import com.google.common.base.Throwables;
import lombok.Getter;
import mops.gruppen2.domain.Exceptions.EventException;
import mops.gruppen2.domain.Exceptions.UserAlreadyExistsException;
import mops.gruppen2.domain.event.Event;
import javax.swing.table.TableRowSorter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static java.lang.String.format;
/**
* Repräsentiert viele Events als aggregiertes Objekt.
*/
@ -18,13 +25,19 @@ public abstract class Aggregate {
*
* @param event Event, welches aggregiert wird
*/
public void applyEvent(Event event) {
public void applyEvent(Event event) throws EventException {
try {
Method method = this.getClass().getDeclaredMethod("applyEvent", event.getClass());
method.setAccessible(true);
method.invoke(this, event);
} catch (Exception e) {
}
catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
EventException f = (EventException) e.getTargetException();
throw f;
}
}
}