Package spark

Class ExceptionMapper


  • public class ExceptionMapper
    extends java.lang.Object
    • Field Detail

      • servletInstance

        private static ExceptionMapper servletInstance
        Holds an exception mapper instance for use in servlet mode
      • exceptionMap

        private java.util.Map<java.lang.Class<? extends java.lang.Exception>,​ExceptionHandlerImpl> exceptionMap
        Holds a map of Exception classes and associated handlers
    • Constructor Detail

      • ExceptionMapper

        public ExceptionMapper()
        Class constructor
    • Method Detail

      • getInstance

        @Deprecated
        public static ExceptionMapper getInstance()
        Deprecated.
      • getServletInstance

        public static ExceptionMapper getServletInstance()
        Returns exception mapper instance used in servlet mode
        Returns:
        servlet instance
      • map

        public void map​(java.lang.Class<? extends java.lang.Exception> exceptionClass,
                        ExceptionHandlerImpl handler)
        Maps the given handler to the provided exception type. If a handler was already registered to the same type, the handler is overwritten.
        Parameters:
        exceptionClass - Type of exception
        handler - Handler to map to exception
      • getHandler

        public ExceptionHandlerImpl getHandler​(java.lang.Class<? extends java.lang.Exception> exceptionClass)
        Returns the handler associated with the provided exception class
        Parameters:
        exceptionClass - Type of exception
        Returns:
        Associated handler
      • getHandler

        public ExceptionHandlerImpl getHandler​(java.lang.Exception exception)
        Returns the handler associated with the provided exception class
        Parameters:
        exception - Exception that occurred
        Returns:
        Associated handler
      • clear

        public void clear()
        Clear the exception mappings.