Interface ExceptionHandler


public interface ExceptionHandler
Interface for custom exception handlers used with ExceptionCatch.

Implementations can be registered as beans and referenced by name in the @ExceptionCatch annotation.

Since:
6.2.0
Author:
wisdomme
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Gets the order of this handler.
    handleException(Throwable exception, Object target, Method method, Object[] args)
    Handles an exception caught during method execution.
    default boolean
    supports(Class<? extends Throwable> exceptionType)
    Determines if this handler supports handling the given exception type.
  • Method Details

    • handleException

      Object handleException(Throwable exception, Object target, Method method, Object[] args) throws Throwable
      Handles an exception caught during method execution.
      Parameters:
      exception - the exception that was caught
      target - the target object whose method threw the exception
      method - the method that threw the exception
      args - the arguments passed to the method
      Returns:
      a replacement return value, or null
      Throws:
      Throwable - if the handler decides to re-throw the exception
    • supports

      default boolean supports(Class<? extends Throwable> exceptionType)
      Determines if this handler supports handling the given exception type.
      Parameters:
      exceptionType - the type of exception
      Returns:
      true if this handler can handle the exception
    • getOrder

      default int getOrder()
      Gets the order of this handler. Lower values have higher priority.
      Returns:
      the handler order