1 23 24 package barracudaDiscRack.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 38 public class ErrorHandler implements HttpPresentation { 39 40 46 public void run(HttpPresentationComms comms) 47 throws HttpPresentationException { 48 ErrorHTML errorPage = (ErrorHTML)comms.xmlcFactory.create(ErrorHTML.class); 49 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 |