1 23 24 package discRack.presentation; 25 26 import com.lutris.logging.*; 27 import com.lutris.appserver.server.httpPresentation.*; 28 import com.lutris.appserver.server.*; 29 import java.io.*; 30 31 36 public class ErrorHandler implements HttpPresentation { 37 38 44 public void run(HttpPresentationComms comms) 45 throws HttpPresentationException { 46 47 ErrorHTML errorPage = (ErrorHTML)comms.xmlcFactory.create(ErrorHTML.class); 48 50 if(null != comms.exception) { 51 StringWriter stringWriter = new StringWriter(); 52 comms.exception.printStackTrace(new PrintWriter(stringWriter)); 53 LogChannel logChannel = Enhydra.getLogChannel(); 54 int level = logChannel.getLevel("DEBUG"); 55 56 logChannel.write(level, "discRack.presentation.ErrorHandler stack trace = "); 57 logChannel.write(level, stringWriter.toString()); 58 logChannel.write(level, "discRack.presentation.ErrorHandler caught an exception - " 59 + comms.exception.toString(), comms.exception); 60 errorPage.setTextStackTrace(stringWriter.toString()); 61 errorPage.setTextErrorMessage(comms.exception.getMessage()); 62 } 63 64 comms.response.writeHTML(errorPage.toDocument()); 65 } 66 } 67 | Popular Tags |