Exception visible in dialog popup

Hi,

Most of the times if issue is occurred on browse screen or any other screen or popup. Exception stacktrace are seen on the dialog box.
I want to show Some general error message like Some Error occur. I dont want to show Error description to the user.

image

Hi Adnan,

What version of Jmix do you use?
You can customize the way Jmix handles the exceptions.

  • By providing your own handlers for any exception - subclass AbstractUiExceptionHandler and register it as a @Component
  • By customizing the dialog shown by the default exception handler. To do this you need to create your dialog class based on ExceptionDialog.

See this doc: Exception Handlers :: Jmix Documentation

Regards,
Sergey.

Jmix version 1.5.0

For exception handling in Jmix 1.5.0 see this doc: Exception Handlers :: Jmix Documentation

Hi,

Can we create common custom message for all exceptions instead of declaring every exception or exception class name

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();
    }
}