Package org.grails.web.errors
Class GrailsExceptionResolver
- java.lang.Object
-
- org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
-
- org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
-
- org.grails.web.errors.GrailsExceptionResolver
-
- All Implemented Interfaces:
grails.core.support.GrailsApplicationAware
,org.springframework.beans.factory.Aware
,org.springframework.core.Ordered
,org.springframework.web.context.ServletContextAware
,org.springframework.web.servlet.HandlerExceptionResolver
public class GrailsExceptionResolver extends org.springframework.web.servlet.handler.SimpleMappingExceptionResolver implements org.springframework.web.context.ServletContextAware, grails.core.support.GrailsApplicationAware
Wraps any runtime exceptions with a GrailsWrappedException instance.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EXCEPTION_ATTRIBUTE
protected grails.core.GrailsApplication
grailsApplication
protected static java.lang.String
LINE_SEPARATOR
protected static org.apache.commons.logging.Log
LOG
protected javax.servlet.ServletContext
servletContext
protected org.grails.exceptions.reporting.StackTraceFilterer
stackFilterer
-
Fields inherited from class org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
DEFAULT_EXCEPTION_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description GrailsExceptionResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createStackFilterer()
protected java.lang.String
determineUri(javax.servlet.http.HttpServletRequest request)
static int
extractLineNumber(org.codehaus.groovy.control.CompilationFailedException e)
protected void
filterStackTrace(java.lang.Exception e)
protected java.lang.Exception
findWrappedException(java.lang.Exception e)
protected void
forwardRequest(grails.web.mapping.UrlMappingInfo info, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv, java.lang.String uri)
static java.lang.RuntimeException
getFirstRuntimeException(java.lang.Throwable e)
protected java.lang.String
getRequestLogMessage(java.lang.String exceptionName, javax.servlet.http.HttpServletRequest request, java.lang.String message)
java.lang.String
getRequestLogMessage(java.lang.Throwable e, javax.servlet.http.HttpServletRequest request)
java.lang.String
getRequestLogMessage(javax.servlet.http.HttpServletRequest request)
static java.lang.Throwable
getRootCause(java.lang.Throwable ex)
Obtains the root cause of the given exceptionprotected void
logStackTrace(java.lang.Exception e, javax.servlet.http.HttpServletRequest request)
protected grails.web.mapping.UrlMappingsHolder
lookupUrlMappings()
protected grails.web.mapping.UrlMappingInfo
matchStatusCode(java.lang.Exception ex, grails.web.mapping.UrlMappingsHolder urlMappings)
org.springframework.web.servlet.ModelAndView
resolveException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
protected void
resolveView(javax.servlet.http.HttpServletRequest request, grails.web.mapping.UrlMappingInfo info, org.springframework.web.servlet.ModelAndView mv)
protected org.springframework.web.servlet.ModelAndView
resolveViewOrForward(java.lang.Exception ex, grails.web.mapping.UrlMappingsHolder urlMappings, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv)
void
setGrailsApplication(grails.core.GrailsApplication grailsApplication)
void
setServletContext(javax.servlet.ServletContext servletContext)
protected void
setStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv, java.lang.Exception e)
-
Methods inherited from class org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
addStatusCode, applyStatusCodeIfPossible, determineStatusCode, determineViewName, doResolveException, findMatchingViewName, getDepth, getModelAndView, getModelAndView, getStatusCodesAsMap, setDefaultErrorView, setDefaultStatusCode, setExceptionAttribute, setExceptionMappings, setExcludedExceptions, setStatusCodes
-
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, setMappedHandlerClasses, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
-
-
-
-
Field Detail
-
EXCEPTION_ATTRIBUTE
public static final java.lang.String EXCEPTION_ATTRIBUTE
- See Also:
- Constant Field Values
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
LINE_SEPARATOR
protected static final java.lang.String LINE_SEPARATOR
-
servletContext
protected javax.servlet.ServletContext servletContext
-
grailsApplication
protected grails.core.GrailsApplication grailsApplication
-
stackFilterer
protected org.grails.exceptions.reporting.StackTraceFilterer stackFilterer
-
-
Method Detail
-
resolveException
public org.springframework.web.servlet.ModelAndView resolveException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
- Specified by:
resolveException
in interfaceorg.springframework.web.servlet.HandlerExceptionResolver
- Overrides:
resolveException
in classorg.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
-
getRequestLogMessage
public java.lang.String getRequestLogMessage(java.lang.Throwable e, javax.servlet.http.HttpServletRequest request)
-
getRequestLogMessage
public java.lang.String getRequestLogMessage(javax.servlet.http.HttpServletRequest request)
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)
- Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
setGrailsApplication
public void setGrailsApplication(grails.core.GrailsApplication grailsApplication)
- Specified by:
setGrailsApplication
in interfacegrails.core.support.GrailsApplicationAware
-
getRootCause
public static java.lang.Throwable getRootCause(java.lang.Throwable ex)
Obtains the root cause of the given exception- Parameters:
ex
- The exception- Returns:
- The root cause
-
extractLineNumber
public static int extractLineNumber(org.codehaus.groovy.control.CompilationFailedException e)
-
getFirstRuntimeException
public static java.lang.RuntimeException getFirstRuntimeException(java.lang.Throwable e)
-
filterStackTrace
protected void filterStackTrace(java.lang.Exception e)
-
setStatus
protected void setStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv, java.lang.Exception e)
-
lookupUrlMappings
protected grails.web.mapping.UrlMappingsHolder lookupUrlMappings()
-
resolveViewOrForward
protected org.springframework.web.servlet.ModelAndView resolveViewOrForward(java.lang.Exception ex, grails.web.mapping.UrlMappingsHolder urlMappings, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv)
-
forwardRequest
protected void forwardRequest(grails.web.mapping.UrlMappingInfo info, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.servlet.ModelAndView mv, java.lang.String uri) throws javax.servlet.ServletException, java.io.IOException
- Throws:
javax.servlet.ServletException
java.io.IOException
-
determineUri
protected java.lang.String determineUri(javax.servlet.http.HttpServletRequest request)
-
resolveView
protected void resolveView(javax.servlet.http.HttpServletRequest request, grails.web.mapping.UrlMappingInfo info, org.springframework.web.servlet.ModelAndView mv) throws java.lang.Exception
- Throws:
java.lang.Exception
-
matchStatusCode
protected grails.web.mapping.UrlMappingInfo matchStatusCode(java.lang.Exception ex, grails.web.mapping.UrlMappingsHolder urlMappings)
-
logStackTrace
protected void logStackTrace(java.lang.Exception e, javax.servlet.http.HttpServletRequest request)
-
findWrappedException
protected java.lang.Exception findWrappedException(java.lang.Exception e)
-
getRequestLogMessage
protected java.lang.String getRequestLogMessage(java.lang.String exceptionName, javax.servlet.http.HttpServletRequest request, java.lang.String message)
-
createStackFilterer
protected void createStackFilterer()
-
-