Class ExceptionHook

  • All Implemented Interfaces:
    Hook

    public class ExceptionHook
    extends Object
    implements Hook
    Configuration for exception interception.
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface Hook
        Returns:
        whether enabled
      • getPriority

        public int getPriority()
        Description copied from interface: Hook
        Gets the priority for ordering multiple hooks at the same point.
        Specified by:
        getPriority in interface Hook
        Returns:
        the priority
      • getExceptionType

        public String getExceptionType()
        Returns:
        the exception type to intercept (internal name), or null for all types
      • isPassException

        public boolean isPassException()
        Returns:
        whether the exception object is passed to the hook
      • isPassMethodName

        public boolean isPassMethodName()
        Returns:
        whether the name of the method where the exception occurred is passed to the hook
      • isPassClassName

        public boolean isPassClassName()
        Returns:
        whether the name of the class where the exception occurred is passed to the hook
      • isCanSuppress

        public boolean isCanSuppress()
        Returns:
        whether the hook can suppress the exception by returning true
      • simple

        public static ExceptionHook simple​(String hookOwner,
                                           String hookName,
                                           String hookDescriptor)
        Creates an exception hook that invokes the given static hook method for all exception types.
        Parameters:
        hookOwner - the hook method's owning class (internal name)
        hookName - the hook method name
        hookDescriptor - the hook method descriptor
        Returns:
        the new hook
      • forType

        public static ExceptionHook forType​(String exceptionType,
                                            String hookOwner,
                                            String hookName,
                                            String hookDescriptor)
        Creates an exception hook restricted to a specific exception type.
        Parameters:
        exceptionType - the exception type to intercept (internal name)
        hookOwner - the hook method's owning class (internal name)
        hookName - the hook method name
        hookDescriptor - the hook method descriptor
        Returns:
        the new hook
      • builder

        public static ExceptionHook.Builder builder()
        Creates a builder for an exception hook.
        Returns:
        a new builder