private StringBuffer getExceptionElement(Throwable throwable) {

        StringBuffer buf = new StringBuffer(256);

        if (!m_writeHtml) {
            if (m_showExceptionStackTrace) {
                buf.append("aT('");
                buf.append(getMessages().key(Messages.RPT_EXCEPTION_0));
                String exception = CmsEncoder.escapeXml(CmsException.getStackTraceAsString(throwable));
                StringBuffer excBuffer = new StringBuffer(exception.length() + 50);
                StringTokenizer tok = new StringTokenizer(exception, "\r\n");
                while (tok.hasMoreTokens()) {
                    excBuffer.append(tok.nextToken());
                    excBuffer.append(getLineBreak());
                }
                buf.append(CmsStringUtil.escapeJavaScript(excBuffer.toString()));
                buf.append("'); ");
            } else {
                buf.append("aT('");
                buf.append(getMessages().key(Messages.RPT_EXCEPTION_0));
                buf.append(CmsStringUtil.escapeJavaScript(throwable.toString()));
                buf.append("'); ");
            }
            m_content.add(buf);
        } else {
            if (m_showExceptionStackTrace) {
                buf.append("<span class='throw'>");
                buf.append(getMessages().key(Messages.RPT_EXCEPTION_0));
                String exception = CmsEncoder.escapeXml(CmsException.getStackTraceAsString(throwable));
                StringBuffer excBuffer = new StringBuffer(exception.length() + 50);
                StringTokenizer tok = new StringTokenizer(exception, "\r\n");
                while (tok.hasMoreTokens()) {
                    excBuffer.append(tok.nextToken());
                    excBuffer.append(getLineBreak());
                }
                buf.append(excBuffer.toString());
                buf.append("</span>");
            } else {
                buf.append("<span class='throw'>");
                buf.append(getMessages().key(Messages.RPT_EXCEPTION_0));
                buf.append(throwable.toString());
                buf.append("</span>");
                buf.append(getLineBreak());
            }
        }
        return buf;
    }
private StringBuffer getExceptionElement ( Throwable throwable ) { StringBuffer buf = new StringBuffer ( 256 ) ; if ( ! m_writeHtml ) { if ( m_showExceptionStackTrace ) { buf . append ( "aT('" ) ; buf . append ( getMessages ( ) . key ( Messages . RPT_EXCEPTION_0 ) ) ; String exception = CmsEncoder . escapeXml ( CmsException . getStackTraceAsString ( throwable ) ) ; StringBuffer excBuffer = new StringBuffer ( exception . length ( ) + 50 ) ; StringTokenizer tok = new StringTokenizer ( exception , "\r\n" ) ; while ( tok . hasMoreTokens ( ) ) { excBuffer . append ( tok . nextToken ( ) ) ; excBuffer . append ( getLineBreak ( ) ) ; } buf . append ( CmsStringUtil . escapeJavaScript ( excBuffer . toString ( ) ) ) ; buf . append ( "'); " ) ; } else { buf . append ( "aT('" ) ; buf . append ( getMessages ( ) . key ( Messages . RPT_EXCEPTION_0 ) ) ; buf . append ( CmsStringUtil . escapeJavaScript ( throwable . toString ( ) ) ) ; buf . append ( "'); " ) ; } m_content . add ( buf ) ; } else { if ( m_showExceptionStackTrace ) { buf . append ( "<span class='throw'>" ) ; buf . append ( getMessages ( ) . key ( Messages . RPT_EXCEPTION_0 ) ) ; String exception = CmsEncoder . escapeXml ( CmsException . getStackTraceAsString ( throwable ) ) ; StringBuffer excBuffer = new StringBuffer ( exception . length ( ) + 50 ) ; StringTokenizer tok = new StringTokenizer ( exception , "\r\n" ) ; while ( tok . hasMoreTokens ( ) ) { excBuffer . append ( tok . nextToken ( ) ) ; excBuffer . append ( getLineBreak ( ) ) ; } buf . append ( excBuffer . toString ( ) ) ; buf . append ( "</span>" ) ; } else { buf . append ( "<span class='throw'>" ) ; buf . append ( getMessages ( ) . key ( Messages . RPT_EXCEPTION_0 ) ) ; buf . append ( throwable . toString ( ) ) ; buf . append ( "</span>" ) ; buf . append ( getLineBreak ( ) ) ; } } return buf ; }
Output helper method to format a reported {@link Throwable} element.<p>

This method ensures that exception stack traces are properly escaped
when they are added to the report.<p>

There is a member variable {@link #m_showExceptionStackTrace} in this
class that controls if the stack track is shown or not.
In a later version this might be configurable on a per-user basis.<p>

@param throwable the exception to format

@return the formatted StringBuffer