KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > DefaultExceptionHandler


1 package com.teamkonzept.lib;
2
3 import org.apache.log4j.Category;
4 import com.teamkonzept.db.*;
5 import com.teamkonzept.web.*;
6 import java.util.*;
7 import java.sql.SQLException JavaDoc;
8
9 /**
10     The default Exception handler
11  * @author $Author: alex $
12  * @version $Revision: 1.10.6.1 $
13 */

14 public class DefaultExceptionHandler implements ConfigurationErrorCodes
15 {
16     
17     /**
18         ist hier erstmal leer -> TK soll das mit Leben fuellen
19         @return true, if the connections must be closed
20     */

21     public static boolean handleException(TKException e, TKEvent evt)
22     {
23         return false;
24     }
25     
26     public static TKException getException(Throwable JavaDoc t)
27     {
28         // prüfen, ob Fehler von der Datenbank stammt
29
if (t instanceof TKSQLError)
30         {
31             SQLException JavaDoc sqlEx = ((TKSQLError)t).getSQLException();
32             if (sqlEx != null)
33                 return DatabaseErrorAnalyzer.getInstance().analyzeSQLError(sqlEx);
34             else
35                 return new TKDatabaseException(t.getMessage(),UNDEFINED, NORMAL_SEVERITY, false, t);
36         }
37         else if (t instanceof SQLException JavaDoc)
38         {
39             return DatabaseErrorAnalyzer.getInstance().analyzeSQLError((SQLException JavaDoc)t);
40         }
41         else if (t instanceof java.lang.OutOfMemoryError JavaDoc)
42         {
43             return new TKConfigurationException("Speicher unzureichend", OUT_OF_MEMORY, HIGH_SEVERITY, false, t);
44         }
45         else if (t instanceof MissingResourceException)
46         {
47             Integer JavaDoc key = new Integer JavaDoc(((MissingResourceException)t).getKey());
48             return new TKConfigurationException("Ressource missing", key.intValue(), HIGH_SEVERITY, false, t);
49         }
50         else if (t instanceof TKException)
51         {
52             return (TKException)t; // ist schon vorher eingeordnet worden
53
}
54         return new TKException("Unbekannter Fehler", UNDEFINED, NORMAL_SEVERITY, false, t); // leider nichts gefunden
55
}
56     
57     //static ResourceBundle bundle = ResourceBundle.getBundle("com.teamkonzept.lib.ExceptionBundle");
58
}
Popular Tags