Implemented Exeption and their handling
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user