Class ErrorReport
- java.lang.Object
-
- org.openidentityplatform.openam.click.util.ErrorReport
-
public class ErrorReport extends Object
Provides an HTML <div> error report for the display of page error information. This class is used by ErrorPage and ClickServlet for the display of error information.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcolumnNumberThe column number of the error, or -1 if not defined.protected ThrowableerrorThe cause of the error.protected booleanisParseErrorThe error is Velocity parsing exception.protected booleanisProductionModeThe application is in "production" mode flag.protected intlineNumberThe line number of the error, or -1 if not defined.protected Class<? extends org.openidentityplatform.openam.click.Page>pageClassThe page class which caused the error.protected jakarta.servlet.http.HttpServletRequestrequestThe servlet request.protected jakarta.servlet.ServletContextservletContextThe servlet context.protected StringsourceNameThe name of the error source.protected LineNumberReadersourceReaderThe error source LineNumberReader.
-
Constructor Summary
Constructors Constructor Description ErrorReport(Throwable error, Class<? extends org.openidentityplatform.openam.click.Page> pageClass, boolean isProductionMode, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.ServletContext servletContext)Create a ErrorReport instance from the given error and page.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ThrowablegetCause()Return the cause of the error.protected intgetColumnNumber()Return the error source column number, or -1 if not determined.protected LineNumberReadergetJavaSourceReader(String filename)Return Java Source LineNumberReader for the given filename, or null if not found.protected intgetLineNumber()Return the error source line number, or -1 if not determined.protected StringgetMessage()Return the error message.protected StringgetRenderedSource()Return a HTML rendered section of the source error with the error line highlighted.protected StringgetRenderJavaLine(String line)Return a HTML rendered Java source line with keywords highlighted using the given line.protected StringgetSourceName()Return the error source name.protected LineNumberReadergetSourceReader()Return a LineNumberReader for the error source file, or null if not defined.protected StringgetStackTrace()Return a HTML encode stack trace string from the given error.protected booleanisParseError()Return true if the error was a Velocity parsing exception.protected booleanisProductionMode()Return true if the application is in "production" mode.protected StringrenderJavaKeywords(String line, String keyword)Render the HTML rendered Java source line with the given keyword highlighted.protected booleanskipLine()Return true if the current line read from the source line reader, should be skipped, or false if the current line should be rendered.StringtoString()Return a error report HTML <div> element for the given error and page.protected voidwriteMap(Map<String,Object> map, org.apache.click.util.HtmlStringBuffer buffer)Write out the map name value pairs as name=value lines to the string buffer.
-
-
-
Field Detail
-
columnNumber
protected int columnNumber
The column number of the error, or -1 if not defined.
-
error
protected final Throwable error
The cause of the error.
-
lineNumber
protected int lineNumber
The line number of the error, or -1 if not defined.
-
isParseError
protected final boolean isParseError
The error is Velocity parsing exception.
-
isProductionMode
protected final boolean isProductionMode
The application is in "production" mode flag.
-
pageClass
protected final Class<? extends org.openidentityplatform.openam.click.Page> pageClass
The page class which caused the error.
-
request
protected final jakarta.servlet.http.HttpServletRequest request
The servlet request.
-
servletContext
protected final jakarta.servlet.ServletContext servletContext
The servlet context.
-
sourceName
protected final String sourceName
The name of the error source.
-
sourceReader
protected LineNumberReader sourceReader
The error source LineNumberReader.
-
-
Constructor Detail
-
ErrorReport
public ErrorReport(Throwable error, Class<? extends org.openidentityplatform.openam.click.Page> pageClass, boolean isProductionMode, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.ServletContext servletContext)
Create a ErrorReport instance from the given error and page.- Parameters:
error- the cause of the errorpageClass- the Page class which caused the errorisProductionMode- the application is in "production" moderequest- the page requestservletContext- the servlet context
-
-
Method Detail
-
toString
public String toString()
Return a error report HTML <div> element for the given error and page. The HTML <div> element 'id' and 'class' attribute values are 'errorReport'.
-
getCause
protected Throwable getCause()
Return the cause of the error.- Returns:
- the cause of the error
-
getColumnNumber
protected int getColumnNumber()
Return the error source column number, or -1 if not determined.- Returns:
- the error source column number, or -1 if not determined
-
isParseError
protected boolean isParseError()
Return true if the error was a Velocity parsing exception.- Returns:
- true if the error was a Velocity parsing exception
-
isProductionMode
protected boolean isProductionMode()
Return true if the application is in "production" mode.- Returns:
- true if the application is in "production" mode
-
getLineNumber
protected int getLineNumber()
Return the error source line number, or -1 if not determined.- Returns:
- the error source line number, or -1 if not determined
-
getMessage
protected String getMessage()
Return the error message.- Returns:
- the error message
-
getSourceName
protected String getSourceName()
Return the error source name.- Returns:
- the error source name
-
getSourceReader
protected LineNumberReader getSourceReader()
Return a LineNumberReader for the error source file, or null if not defined.- Returns:
- LineNumberReader for the error source file, or null if not defined
-
getJavaSourceReader
protected LineNumberReader getJavaSourceReader(String filename) throws FileNotFoundException
Return Java Source LineNumberReader for the given filename, or null if not found.- Parameters:
filename- the name of the Java source file, e.g. /examples/Page.java- Returns:
- LineNumberReader for the given source filename, or null if not found
- Throws:
FileNotFoundException- if file could not be found
-
getRenderedSource
protected String getRenderedSource()
Return a HTML rendered section of the source error with the error line highlighted.- Returns:
- a HTML rendered section of the parsing error page template
-
getStackTrace
protected String getStackTrace()
Return a HTML encode stack trace string from the given error.- Returns:
- a HTML encode stack trace string.
-
writeMap
protected void writeMap(Map<String,Object> map, org.apache.click.util.HtmlStringBuffer buffer)
Write out the map name value pairs as name=value lines to the string buffer.- Parameters:
map- the Map of name value pairsbuffer- the string buffer to write out the values to
-
getRenderJavaLine
protected String getRenderJavaLine(String line)
Return a HTML rendered Java source line with keywords highlighted using the given line.- Parameters:
line- the Java source line to render- Returns:
- HTML rendered Java source line
-
renderJavaKeywords
protected String renderJavaKeywords(String line, String keyword)
Render the HTML rendered Java source line with the given keyword highlighted.- Parameters:
line- the given Java source line to renderkeyword- the Java keyword to highlight- Returns:
- the HTML rendered Java source line with the given keyword highlighted
-
skipLine
protected boolean skipLine()
Return true if the current line read from the source line reader, should be skipped, or false if the current line should be rendered.- Returns:
- true if the current line from the source reader should be skipped
-
-