use of com.tvd12.ezyfoxserver.support.asm.EzyExceptionHandlerImplementer in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlersImplementer method implement.
public Map<Class<?>, EzyUncaughtExceptionHandler> implement(Object exceptionHandler) {
Map<Class<?>, EzyUncaughtExceptionHandler> handlers = new HashMap<>();
EzyExceptionHandlerProxy proxy = new EzyExceptionHandlerProxy(exceptionHandler);
for (EzyExceptionHandlerMethod method : proxy.getExceptionHandlerMethods()) {
EzyExceptionHandlerImplementer implementer = newImplementer(proxy, method);
EzyUncaughtExceptionHandler handler = implementer.implement();
for (Class<?> exceptionClass : method.getExceptionClasses()) {
handlers.put(exceptionClass, handler);
}
}
return handlers;
}
use of com.tvd12.ezyfoxserver.support.asm.EzyExceptionHandlerImplementer in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerImplementerTest method testFailedCase.
@Test(expectedExceptions = IllegalStateException.class)
public void testFailedCase() throws Exception {
EzyExceptionHandlerProxy handlerProxy = new EzyExceptionHandlerProxy(new ExceptionHandlerFail());
EzyExceptionHandlerMethod method = new EzyExceptionHandlerMethod(new EzyMethod(ExceptionHandlerFail.class.getDeclaredMethod("handle", Exception.class, int.class)));
new EzyExceptionHandlerImplementer(handlerProxy, method) {
@SuppressWarnings("rawtypes")
@Override
protected EzyUncaughtExceptionHandler doImplement() {
throw new IllegalStateException("test");
}
}.implement();
}
Aggregations