Class AbstractUiExceptionHandler

java.lang.Object
io.jmix.ui.exception.AbstractUiExceptionHandler
All Implemented Interfaces:
UiExceptionHandler
Direct Known Subclasses:
AccessDeniedExceptionHandler, DeletePolicyExceptionHandler, FileStorageExceptionHandler, LayerLoadingExceptionHandler, OptimisticLockExceptionHandler, ReportExceptionHandler, WebdavExceptionHandler

public abstract class AbstractUiExceptionHandler extends Object implements UiExceptionHandler
Base class for exception handlers determining their ability to handle an exception by its class name and optional implementation of canHandle(String, String, Throwable) method.

If you need to handle a specific exception, create a descendant of this class, pass handled exception class names into constructor, implement doHandle(String, String, Throwable, UiContext) method and annotate the class with @Component.

  • Field Details

  • Constructor Details

    • AbstractUiExceptionHandler

      public AbstractUiExceptionHandler(String... classNames)
  • Method Details

    • handle

      public boolean handle(Throwable exception, UiExceptionHandler.UiContext context)
      Description copied from interface: UiExceptionHandler
      Handle an exception. Implementation class should either handle the exception and return true, or return false to delegate execution to the next handler in the chain of responsibility.
      Specified by:
      handle in interface UiExceptionHandler
      Parameters:
      exception - exception instance
      context - UI context
      Returns:
      true if the exception has been successfully handled, false if not
    • canHandle

      protected boolean canHandle(String className, String message, @Nullable Throwable throwable)
      Should be implemented in subclasses if the exception class name is not enough to determine the ability to handle the exception.
      Parameters:
      className - exception class name
      message - exception message
      throwable - exception instance. Can be null if the exception occurred on the server side and this exception class isn't accessible by the client.
      Returns:
      true if the exception can be handled by this handler
    • doHandle

      protected abstract void doHandle(String className, String message, @Nullable Throwable throwable, UiExceptionHandler.UiContext context)
      Perform exception handling.
      Parameters:
      className - actual exception class name
      message - exception message
      throwable - exception instance. Can be null if the exception occurred on the server side and this exception class isn't accessible by the client.
      context - UI context