1 25 package org.archive.crawler.io; 26 27 import java.io.PrintWriter ; 28 import java.io.StringWriter ; 29 import java.util.logging.LogRecord ; 30 31 import org.archive.crawler.datamodel.CoreAttributeConstants; 32 import org.archive.crawler.datamodel.CrawlURI; 33 34 42 public class RuntimeErrorFormatter extends UriProcessingFormatter 43 implements CoreAttributeConstants { 44 public String format(LogRecord lr) { 45 Object [] parameters = lr.getParameters(); 46 String stackTrace = "None retrieved"; 47 if (parameters != null) { 48 CrawlURI curi = (CrawlURI)parameters[0]; 50 if (curi != null) { 51 Throwable t = (Throwable )curi.getObject(A_RUNTIME_EXCEPTION); 52 assert t != null : "Null throwable"; 53 StringWriter sw = new StringWriter (); 54 if (t == null) { 55 sw.write("No exception to report."); 56 } else { 57 t.printStackTrace(new PrintWriter (sw)); 58 } 59 stackTrace = sw.toString(); 60 } 61 } 62 return super.format(lr) + " " + stackTrace; 63 } 64 } 65 | Popular Tags |