Package spark
Class ExceptionMapper
- java.lang.Object
-
- spark.ExceptionMapper
-
public class ExceptionMapper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Class<? extends java.lang.Exception>,ExceptionHandlerImpl>
exceptionMap
Holds a map of Exception classes and associated handlersprivate static ExceptionMapper
servletInstance
Holds an exception mapper instance for use in servlet mode
-
Constructor Summary
Constructors Constructor Description ExceptionMapper()
Class constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clear()
Clear the exception mappings.ExceptionHandlerImpl
getHandler(java.lang.Class<? extends java.lang.Exception> exceptionClass)
Returns the handler associated with the provided exception classExceptionHandlerImpl
getHandler(java.lang.Exception exception)
Returns the handler associated with the provided exception classstatic ExceptionMapper
getInstance()
Deprecated.static ExceptionMapper
getServletInstance()
Returns exception mapper instance used in servlet modevoid
map(java.lang.Class<? extends java.lang.Exception> exceptionClass, ExceptionHandlerImpl handler)
Maps the given handler to the provided exception type.
-
-
-
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
-
-
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 exceptionhandler
- 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.
-
-