1
2
3 package org.opensync.tools.exception;
4
5 import org.opensync.tools.exception.OpenSyncException;
6 import java.sql.*;
7
8 /*** Class for catching the Runtime Exceptions such as IndexOutOfBound,
9 * Invalid Arithmetic Operation, Database Exceptions or the dreaded
10 * "NullPointerException!!!!" etc etc...
11 */
12
13 public class APSystemException extends OpenSyncException {
14
15 /*** Error messages corresponding to these error codes
16 * to be retrieved from DICO.
17 *
18 * Error Codes --
19 * SysError_default = "THE SYSTEM ENCOUNTERED AN ERROR";
20 * SysError_index_out_of_bounds = "INDEX OUT OF BOUNDS";
21 * SysError_invalid_arithmetic_operation = "AN INVALID ARITHMETIC OPERATION OCCURED";
22 * SysError_runtime_error = "A RUNTIME ERROR OCCURED";
23 * SysError_sql_error = "ERROR IN DATABASE TRANSACTION";
24 * SysError_invalid_object_access = "TRYING TO ACCESS NON EXISTING OBJECT";
25 */
26
27 /*** Creates a APSystemException. Use this constructor when you know what
28 * Error Code should be set in the AssetPlusException
29 */
30 public APSystemException(String errorCode, Throwable e)
31 {
32 super(errorCode, e);
33 }
34
35 /*** Creates a APSystemException. Use this constructor when Error Code
36 * to be set in the AssetPlusException is not known. We try to find
37 * the actual Exception here, if we don't get it set the ErrorCode
38 * to be default for this type of Exception.
39 */
40 public APSystemException(Throwable e)
41 {
42 super(e);
43
44 if(e instanceof IndexOutOfBoundsException )
45 {
46 errorCode = "SysError_index_out_of_bounds";
47 }
48 else if(e instanceof ArithmeticException)
49 {
50 errorCode = "SysError_invalid_arithmetic_operation";
51 }
52 else if(e instanceof NullPointerException)
53 {
54 errorCode = "SysError_invalid_object_access";
55 }
56 else if(e instanceof RuntimeException)
57 {
58 errorCode = "SysError_runtime_error";
59 }
60 else if(e instanceof SQLException)
61 {
62 errorCode = "SysError_sql_error";
63 }
64 else if (e instanceof OutOfMemoryError )
65 {
66 errorCode = "SysError_out_of_memory";
67
68 }
69 else
70 {
71 errorCode = "SysError_default";
72 }
73
74
75 }
76 }