To bypass the default process of calling exception handlers, you can override the handle
method in your exception handler.
You may need to also set a higher precedence to your exception handler, for example, @Order(JmixOrder.HIGHEST_PRECEDENCE - 10)
.
Example:
@Component("demo_CustomExceptionHandler")
@Order(JmixOrder.HIGHEST_PRECEDENCE - 50)
public class CustomExceptionHandler extends AbstractUiExceptionHandler {
@Override
public boolean handle(Throwable exception, UiContext context) {
doHandle(exception.getClass().getName(), exception.getMessage(), exception, context);
return true;
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, UiContext context) {
context.getNotifications().create(Notifications.NotificationType.ERROR)
.withCaption("Error")
.withDescription(message)
.show();
}
}