KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > xmlEngine > ErrorManagement


1 /*
2  ************************************************************************************
3  * Copyright (C) 2001-2006 Openbravo S.L.
4  * Licensed under the Apache Software License version 2.0
5  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6  * Unless required by applicable law or agreed to in writing, software distributed
7  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8  * CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations under the License.
10  ************************************************************************************
11 */

12 package org.openbravo.xmlEngine;
13
14 /* Error management for XmlEngine
15     To add a new error, in the location where the error is produced include:
16     ErrorManagement.error(nn, location [, exception]);
17     In this file include the block
18     case nn:
19     errorText = "Description of the error";
20 // comments of the error
21 break;
22 */

23 import org.apache.log4j.Logger ;
24
25 public class ErrorManagement {
26
27   static Logger log4jErrorManagement = Logger.getLogger(ErrorManagement.class);
28
29   public static void error(int i, String JavaDoc locationText) {
30     error(i, locationText, null);
31   }
32
33   public static void error(int i, String JavaDoc locationText, Exception JavaDoc e) {
34     String JavaDoc errorText = "";
35     switch(i) {
36       case 101:
37         errorText = "Data not defined for structure";
38         // The setData has not been made in the structure of a XmlDocument
39
// or a sql sentece was not specified in the configuration file
40
break;
41       case 102:
42         errorText = "Not found fileXmlEngineConfiguration";
43         // the .xml file does not exist
44
break;
45       case 103:
46         errorText = "IOException in fileXmlEngineConfiguration";
47         break;
48       case 104:
49         errorText = "Exception in parsing of fileXmlEngineConfiguration";
50         // error when parsing the .xml file, for example badly nested tags
51
// or badly closed
52
break;
53       case 105:
54         errorText = "File of template not defined";
55         // no template found in the xml file
56
break;
57       case 106:
58         errorText = "Not found fileXmlEngineTemplate";
59         // the template file does not exist (.html, .xml, ...)
60
break;
61       case 107:
62         errorText = "IOException in fileXmlEngineTemplate";
63         break;
64       case 108:
65         errorText = "Exception in parsing of fileXmlEngineTemplate";
66         // error when parsing the .xml file, for example badly nested tags
67
// or badly closed
68
break;
69     }
70     log4jErrorManagement.error(errorText);
71     log4jErrorManagement.error("in " + locationText);
72     if (log4jErrorManagement.isDebugEnabled() && e != null) {
73       e.getMessage();
74       e.printStackTrace();
75     }
76
77   }
78
79 }
80
Popular Tags