KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > messenger > ErrorHandler


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * 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 2004/08/16 09:33:18 slobodan 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 JavaDoc;
30
31
32 /**
33  * Class to handle exceptions not caught anywhere else in the framework of
34  * our application
35  *
36  * @author
37  * @version
38  */

39 public class ErrorHandler implements HttpPresentation {
40
41     /**
42      * This implements the run method in HttpPresentation.
43      *
44      * @param HttpPresentationComms
45      * @exception HttpPresentationException
46      */

47     public void run(HttpPresentationComms comms)
48         throws HttpPresentationException {
49         Class JavaDoc tempClass=null;
50     Object JavaDoc page= null;
51     Method JavaDoc setTextErrorMessage = null;
52   
53     try{
54     Class JavaDoc stringClass=Class.forName("java.lang.String");
55     tempClass = Class.forName(DeviceUtils.getPageName(comms, "com.lutris.airsent.presentation.messenger.Error"));
56     page= comms.xmlcFactory.create(tempClass);
57     Class JavaDoc[] argTypeArr={stringClass};
58     setTextErrorMessage = tempClass.getMethod("setTextErrorMessage",argTypeArr);
59   }catch(Exception JavaDoc e){}
60     
61     
62     //ErrorPage errorPage = (ErrorPage)comms.xmlcFactory.create(DeviceUtils.getPageName(comms,
63
// "com.lutris.airsent.presentation.messenger.Error"));
64
try{
65     if (null != comms.exception) {
66         Enhydra.getLogChannel().write(Logger.DEBUG,
67                       "Exception in Airsent",
68                       comms.exception);
69         System.out.println("Setting ERROR page..");
70         Object JavaDoc [] 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 JavaDoc e){}
79     try {
80         comms.response.writeDOM((XMLObject)page);
81     } catch (Exception JavaDoc ex) {
82         throw new HttpPresentationException(ex);
83     }
84     }
85
86 }
87
88
Popular Tags