org.bbqjs.spring.mvc
Class ErrorController

java.lang.Object
  extended by org.bbqjs.spring.mvc.ErrorController
All Implemented Interfaces:
org.springframework.web.servlet.HandlerExceptionResolver

public class ErrorController
extends Object
implements org.springframework.web.servlet.HandlerExceptionResolver

Maps exceptions to error codes. Set the errorCodes map to do custom error mapping.

Author:
alex

Field Summary
static int EPIC_FAIL_CODE
          Default error code.
static String X_BBQ_RESPONSE_MESSAGE
           
static String X_BBQ_RESPONSE_TYPE
           
 
Constructor Summary
ErrorController()
           
 
Method Summary
protected  void encounteredError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception exception)
          Override this to do logging, etc
protected  int getErrorCode(Exception exception)
           
protected  String getErrorMessage(Exception exception)
           
protected  org.springframework.web.servlet.ModelAndView getModelAndView(Exception forException)
           
 org.springframework.web.servlet.ModelAndView resolveException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception exception)
           
 void setDefaultErrorView(String defaultErrorView)
          The name of the default view which is returned if ErrorController#errorViews doesn't contain a specific view for the thrown exception.
 void setErrorCodes(Map<Class<?>,Integer> errorCodes)
           
 void setErrorViews(Map<Class<?>,String> errorViews)
          A list of view template names keyed by exception class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPIC_FAIL_CODE

public static final int EPIC_FAIL_CODE
Default error code.

See Also:
Constant Field Values

X_BBQ_RESPONSE_TYPE

public static final String X_BBQ_RESPONSE_TYPE
See Also:
Constant Field Values

X_BBQ_RESPONSE_MESSAGE

public static final String X_BBQ_RESPONSE_MESSAGE
See Also:
Constant Field Values
Constructor Detail

ErrorController

public ErrorController()
Method Detail

resolveException

public org.springframework.web.servlet.ModelAndView resolveException(javax.servlet.http.HttpServletRequest request,
                                                                     javax.servlet.http.HttpServletResponse response,
                                                                     Object handler,
                                                                     Exception exception)
Specified by:
resolveException in interface org.springframework.web.servlet.HandlerExceptionResolver

encounteredError

protected void encounteredError(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                Exception exception)
Override this to do logging, etc

Parameters:
exception -

getErrorMessage

protected String getErrorMessage(Exception exception)
                          throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

getErrorCode

protected int getErrorCode(Exception exception)

getModelAndView

protected org.springframework.web.servlet.ModelAndView getModelAndView(Exception forException)

setErrorCodes

public void setErrorCodes(Map<Class<?>,Integer> errorCodes)

setErrorViews

public void setErrorViews(Map<Class<?>,String> errorViews)
A list of view template names keyed by exception class. The list will be consulted and the exception-specific view name returned if available.

Parameters:
errorViews -

setDefaultErrorView

public void setDefaultErrorView(String defaultErrorView)
The name of the default view which is returned if ErrorController#errorViews doesn't contain a specific view for the thrown exception.

Parameters:
defaultErrorView -


Copyright © 2012. All Rights Reserved.