01: /*
02: * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
03: * Reserved.
04: *
05: * This source code file is distributed by Lutris Technologies, Inc. for
06: * use only by licensed users of product(s) that include this source
07: * file. Use of this source file or the software that uses it is covered
08: * by the terms and conditions of the Lutris Enhydra Development License
09: * Agreement included with this product.
10: *
11: * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12: * ANY KIND, either express or implied. See the License for the specific terms
13: * governing rights and limitations under the License.
14: *
15: * Contributor(s):
16: *
17: * $Id: ErrorHandler.java,v 1.1 2006-09-11 12:29:26 sinisa Exp $
18: */
19:
20: package com.lutris.airsent.presentation.messenger;
21:
22: import com.lutris.logging.*;
23: import com.lutris.appserver.server.httpPresentation.*;
24: import com.lutris.appserver.server.*;
25: import java.io.*;
26: import org.enhydra.xml.xmlc.XMLCUtil;
27: import com.lutris.airsent.presentation.DeviceUtils;
28: import org.enhydra.xml.xmlc.XMLObject;
29: import java.lang.reflect.Method;
30:
31: /**
32: * Class to handle exceptions not caught anywhere else in the framework of
33: * our application
34: *
35: * @author
36: * @version
37: */
38: public class ErrorHandler implements HttpPresentation {
39:
40: /**
41: * This implements the run method in HttpPresentation.
42: *
43: * @param HttpPresentationComms
44: * @exception HttpPresentationException
45: */
46: public void run(HttpPresentationComms comms)
47: throws HttpPresentationException {
48: Class tempClass = null;
49: Object page = null;
50: Method setTextErrorMessage = null;
51:
52: try {
53: Class stringClass = Class.forName("java.lang.String");
54: tempClass = Class.forName(DeviceUtils.getPageName(comms,
55: "com.lutris.airsent.presentation.messenger.Error"));
56: page = comms.xmlcFactory.create(tempClass);
57: Class[] argTypeArr = { stringClass };
58: setTextErrorMessage = tempClass.getMethod(
59: "setTextErrorMessage", argTypeArr);
60: } catch (Exception e) {
61: }
62:
63: //ErrorPage errorPage = (ErrorPage)comms.xmlcFactory.create(DeviceUtils.getPageName(comms,
64: // "com.lutris.airsent.presentation.messenger.Error"));
65: try {
66: if (null != comms.exception) {
67: Enhydra.getLogChannel().write(Logger.DEBUG,
68: "Exception in Airsent", comms.exception);
69: System.out.println("Setting ERROR page..");
70: Object[] temp = { (comms.exception.getMessage()) };
71: setTextErrorMessage.invoke(page, temp);
72: //errorPage.setTextErrorMessage((comms.exception.getMessage()));
73:
74: //StringWriter stringWriter = new StringWriter();
75: //comms.exception.printStackTrace(new PrintWriter(stringWriter));
76: //errorPage.setTextStackTrace(stringWriter.toString());
77: }
78: } catch (Exception e) {
79: }
80: try {
81: comms.response.writeDOM((XMLObject) page);
82: } catch (Exception ex) {
83: throw new HttpPresentationException(ex);
84: }
85: }
86:
87: }
|