<commit_before>package net.lucenews.controller;

import net.lucenews.atom.*;
import net.lucenews.*;
import net.lucenews.model.*;
import net.lucenews.model.exception.*;
import net.lucenews.view.*;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class ExceptionController extends Controller
{
	
	public static void process (LuceneContext c, Exception e)
	{
		try
		{
			process( c, e, ServletUtils.parseBoolean( c.service().getProperty( "service.debugging" ) ) );
		}
		catch(IOException ioe)
		{
		}
	}
	
	public static void process (LuceneContext c, Exception e, boolean doStackTrace)
	{
		LuceneWebService   service = c.service();
		LuceneIndexManager manager = service.getIndexManager();
		LuceneRequest      req     = c.req();
		LuceneResponse     res     = c.res();
		
		
		
		try
		{
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document document = builder.newDocument();
			
			

			
			
			
			Entry entry = new Entry();
			entry.setTitle( e.getClass().getSimpleName() );
			entry.setUpdated( Calendar.getInstance() );
			entry.setID( req.getLocation() );
			entry.setSummary( new Text( e.getMessage() ) );
			entry.setContent( Content.text( e.getMessage() ) );
			entry.addAuthor( new Author( service.getTitle() ) );
			
			
			
			
			
			
			/**
			 * Get the stack trace ready, if necessary.
			 */
			if( doStackTrace )
			{
				Element div = document.createElement( "div" );
				
				Element trace = document.createElement( "trace" );
				
				StackTraceElement[] stack = e.getStackTrace();
				for( int i = 0; i < stack.length; i++ )
				{
					Element element = document.createElement( "element" );
					element.appendChild( document.createTextNode( stack[i].toString() ) );
					trace.appendChild( element );
				}
				
				div.appendChild( trace );
				
				entry.setContent( Content.xhtml( div ) );
			}
			
			
			AtomView.process( c, entry );
		}
		catch(Exception ee)
		{
		}
	}
	
}
<commit_msg>While debugging, an ordered list containing the exception's stack trace is contained within the entry's content element. This replaces proprietary XML used beforehand.<commit_after>package net.lucenews.controller;

import net.lucenews.atom.*;
import net.lucenews.*;
import net.lucenews.model.*;
import net.lucenews.model.exception.*;
import net.lucenews.view.*;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class ExceptionController extends Controller
{
	
	public static void process (LuceneContext c, Exception e)
	{
		try
		{
			process( c, e, ServletUtils.parseBoolean( c.service().getProperty( "service.debugging" ) ) );
		}
		catch(IOException ioe)
		{
		}
	}
	
	public static void process (LuceneContext c, Exception e, boolean doStackTrace)
	{
		LuceneWebService   service = c.service();
		LuceneIndexManager manager = service.getIndexManager();
		LuceneRequest      req     = c.req();
		LuceneResponse     res     = c.res();
		
		
		
		try
		{
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document document = builder.newDocument();
			
			

			
			
			
			Entry entry = new Entry();
			entry.setTitle( e.getClass().getSimpleName() );
			entry.setUpdated( Calendar.getInstance() );
			entry.setID( req.getLocation() );
			entry.setSummary( new Text( e.getMessage() ) );
			entry.setContent( Content.text( e.getMessage() ) );
			entry.addAuthor( new Author( service.getTitle() ) );
			
			
			
			
			
			
			/**
			 * Get the stack trace ready, if necessary.
			 */
			if( doStackTrace )
			{
				Element div = document.createElement( "div" );
				div.setAttribute( "xmlns", XMLController.getXHTMLNamespace() );
				
				Element ol = document.createElement( "ol" );
				
				StackTraceElement[] stack = e.getStackTrace();
				for( int i = 0; i < stack.length; i++ )
				{
					Element li = document.createElement( "li" );
					li.appendChild( document.createTextNode( stack[ i ].toString() ) );
					ol.appendChild( li );
				}
				
				div.appendChild( ol );
				
				entry.setContent( Content.xhtml( div ) );
			}
			
			
			AtomView.process( c, entry );
		}
		catch(Exception ee)
		{
		}
	}
	
}

{'fraction_non_alphanumeric': 0.11620048807959452, 'fraction_numerical': 0.0011263375258119017, 'mean_word_length': 2.9004392386530014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 19}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503399', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1552, 'n_words': 345}