use of com.haulmont.cuba.gui.exception.UiExceptionHandler in project cuba by cuba-platform.
the class ExceptionHandlers method createByConfiguration.
/**
* Create all handlers defined by <code>ExceptionHandlersConfiguration</code> beans in spring.xml and
* GUI handlers defined as Spring-beans.
*/
public void createByConfiguration() {
removeAll();
// Desktop handlers
Map<String, ExceptionHandlersConfiguration> map = AppBeans.getAll(ExceptionHandlersConfiguration.class);
// Project-level handlers must run before platform-level
List<ExceptionHandlersConfiguration> configurations = new ArrayList<>(map.values());
Collections.reverse(configurations);
for (ExceptionHandlersConfiguration conf : configurations) {
for (Class aClass : conf.getHandlerClasses()) {
try {
handlers.add(ReflectionHelper.<ExceptionHandler>newInstance(aClass));
} catch (NoSuchMethodException e) {
log.error("Unable to instantiate " + aClass, e);
}
}
}
// GUI handlers
Map<String, UiExceptionHandler> handlerMap = AppBeans.getAll(UiExceptionHandler.class);
List<UiExceptionHandler> handlers = new ArrayList<>(handlerMap.values());
Collections.sort(handlers, new OrderComparator());
for (UiExceptionHandler handler : handlers) {
addHandler(handler);
}
}
use of com.haulmont.cuba.gui.exception.UiExceptionHandler in project cuba by cuba-platform.
the class ExceptionHandlers method handle.
/**
* Delegates exception handling to registered handlers.
*
* @param event error event generated by Vaadin
*/
public void handle(ErrorEvent event) {
for (ExceptionHandler handler : handlers) {
if (handler.handle(event, app)) {
return;
}
}
AppUI ui = app.getAppUI();
if (ui != null) {
for (UiExceptionHandler handler : genericHandlers) {
if (handler.handle(event.getThrowable(), ui)) {
return;
}
}
}
defaultHandler.handle(event, app);
}
use of com.haulmont.cuba.gui.exception.UiExceptionHandler in project cuba by cuba-platform.
the class ExceptionHandlers method createByConfiguration.
/**
* Create all Web handlers defined by <code>ExceptionHandlersConfiguration</code> beans in spring.xml and
* GUI handlers defined as Spring-beans.
*/
public void createByConfiguration() {
removeAll();
// Web handlers
Map<String, ExceptionHandlersConfiguration> map = beanLocator.getAll(ExceptionHandlersConfiguration.class);
// Project-level handlers must run before platform-level
List<ExceptionHandlersConfiguration> configurations = new ArrayList<>(map.values());
Collections.reverse(configurations);
for (ExceptionHandlersConfiguration conf : configurations) {
for (Class aClass : conf.getHandlerClasses()) {
try {
ExceptionHandler handler = ReflectionHelper.<ExceptionHandler>newInstance(aClass);
if (handler instanceof BeanLocatorAware) {
((BeanLocatorAware) handler).setBeanLocator(beanLocator);
}
addHandler(handler);
} catch (NoSuchMethodException e) {
log.error("Unable to instantiate {}", aClass, e);
}
}
}
// GUI handlers
Map<String, UiExceptionHandler> handlerMap = beanLocator.getAll(UiExceptionHandler.class);
List<UiExceptionHandler> handlers = new ArrayList<>(handlerMap.values());
handlers.sort(new OrderComparator());
for (UiExceptionHandler handler : handlers) {
addHandler(handler);
}
}
Aggregations