1 package org.opensync.tools.exception;
2
3 import java.sql.SQLException;
4
5 import org.xml.sax.SAXException;
6
7
8 /*** Class for catching the Data Integrity related Exceptions such as SQLException,
9 * Invalid XML etc...
10 */
11 public class APDataIntegrityException extends OpenSyncException {
12 /***
13 * Error Codes ---
14 * DIError_default_message = "INVALID DATA";
15 * DIError_sql_error = "AN ERROR OCCURED IN DATABASE TRANSACTION";
16 * DIError_error_parsing_xml = "AN ERROR OCCURED WHILE PARSING THE INPUT XML";
17 *
18 */
19
20 /*** Creates a APDataIntegrityException. Use this constructor when Error Code
21 * to be set in the AssetPlusException is not known. We try to find
22 * the actual Exception here, if we don't get it set the ErrorCode
23 * to be default for this type of Exception.
24 */
25 public APDataIntegrityException(Throwable e)
26 {
27 super(e);
28 if(e instanceof SQLException)
29 {
30 errorCode = "DIError_sql_error";
31 }
32 else if (e instanceof SAXException )
33 {
34 errorCode = "DIError_error_parsing_xml";
35 }
36 else
37 {
38 errorCode = "DIError_default";
39 }
40 }
41
42 /*** Creates a APDataIntegrityException. Use this constructor when you know what
43 * Error Code should be set in the AssetPlusException
44 */
45 public APDataIntegrityException(String errorCode, Throwable e)
46 {
47 super(errorCode, e);
48 }
49
50 public APDataIntegrityException(String errorCode)
51 {
52 super(errorCode);
53 }
54 }