Package spark

Class ExceptionMapper

java.lang.Object
spark.ExceptionMapper

public class ExceptionMapper extends Object
  • Field Details

    • servletInstance

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

      private Map<Class<? extends Exception>,ExceptionHandlerImpl> exceptionMap
      Holds a map of Exception classes and associated handlers
  • Constructor Details

    • ExceptionMapper

      public ExceptionMapper()
      Class constructor
  • Method Details

    • 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(Class<? extends 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(Class<? extends Exception> exceptionClass)
      Returns the handler associated with the provided exception class
      Parameters:
      exceptionClass - Type of exception
      Returns:
      Associated handler
    • getHandler

      public ExceptionHandlerImpl getHandler(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.