| 119 |
ghuddy |
1 |
<%
|
|
|
2 |
'=============================================================
|
|
|
3 |
'//
|
|
|
4 |
'// Exception Handler
|
|
|
5 |
'//
|
|
|
6 |
'// version: 1.4
|
|
|
7 |
'// last modified: 20-Jul-2004 14:17 by Sasha Vukovic
|
|
|
8 |
'=============================================================
|
|
|
9 |
%>
|
|
|
10 |
<%
|
|
|
11 |
'------------- GLOBALS --------------
|
|
|
12 |
Const enumEXCEPTION_HANDLER_SESSION = "DM_EXCEPTION_HANDLER"
|
|
|
13 |
'------------------------------------
|
|
|
14 |
%>
|
|
|
15 |
<%
|
|
|
16 |
Class ExceptionHandler
|
|
|
17 |
|
|
|
18 |
Private sMsgSummary
|
|
|
19 |
Private sMsgDetails
|
|
|
20 |
Private bIsDisplayed
|
|
|
21 |
Private bErrorRedirect
|
|
|
22 |
|
|
|
23 |
Private SEPARATOR
|
|
|
24 |
|
|
|
25 |
Public Property Let ErrorRedirect ( bVal )
|
|
|
26 |
bErrorRedirect = bVal
|
|
|
27 |
Session( enumEXCEPTION_HANDLER_SESSION ) = NULL ' Clear message session variable
|
|
|
28 |
End Property
|
|
|
29 |
|
|
|
30 |
Public Property Get MessageSummary
|
|
|
31 |
MessageSummary = sMsgSummary
|
|
|
32 |
bIsDisplayed = TRUE
|
|
|
33 |
End Property
|
|
|
34 |
|
|
|
35 |
Public Property Get MessageDetails
|
|
|
36 |
MessageDetails = sMsgDetails
|
|
|
37 |
bIsDisplayed = TRUE
|
|
|
38 |
End Property
|
|
|
39 |
|
|
|
40 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
41 |
Public Sub LogAction ( nUserId, nEvent, sMethod, sActionScript, sDescription, ByRef OraDatabase )
|
|
|
42 |
OraDatabase.ExecuteSQL _
|
|
|
43 |
"BEGIN pk_Utils.Log_Action ( "&_
|
|
|
44 |
nUserId &","&_
|
|
|
45 |
nEvent &","&_
|
|
|
46 |
"'"& sMethod &"',"&_
|
|
|
47 |
"'"& sActionScript &"',"&_
|
|
|
48 |
"'"& sDescription &"'"&_
|
|
|
49 |
" ); "&_
|
|
|
50 |
"END;"
|
|
|
51 |
End Sub
|
|
|
52 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
53 |
Public Function Finally ()
|
|
|
54 |
If IsNull( sMsgSummary ) OR bErrorRedirect Then
|
|
|
55 |
Finally = TRUE
|
|
|
56 |
Else
|
|
|
57 |
Finally = FALSE
|
|
|
58 |
End If
|
|
|
59 |
End Function
|
|
|
60 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
61 |
Public Sub Try ()
|
|
|
62 |
Err.Clear
|
|
|
63 |
End Sub
|
|
|
64 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
65 |
Public Sub Catch ()
|
|
|
66 |
|
|
|
67 |
If Err.Number <> 0 Then
|
|
|
68 |
|
|
|
69 |
If IsNull( sMsgSummary ) Then
|
|
|
70 |
sMsgSummary = Err.Source
|
|
|
71 |
sMsgDetails = Err.Description
|
|
|
72 |
End If
|
|
|
73 |
|
|
|
74 |
' Redirect to Message
|
|
|
75 |
If bErrorRedirect Then
|
|
|
76 |
Session( enumEXCEPTION_HANDLER_SESSION ) = sMsgSummary & SEPARATOR & sMsgDetails
|
|
|
77 |
Call OpenInWindow ( "messages/msgPleaseNote.asp" )
|
|
|
78 |
bIsDisplayed = TRUE
|
|
|
79 |
End If
|
|
|
80 |
|
|
|
81 |
End If
|
|
|
82 |
|
|
|
83 |
Err.Clear
|
|
|
84 |
End Sub
|
|
|
85 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
86 |
Public Sub TryORA ( ByRef objOraSession )
|
|
|
87 |
Err.Clear
|
|
|
88 |
' Begin DB transaction
|
|
|
89 |
objOraSession.BeginTrans
|
|
|
90 |
|
|
|
91 |
End Sub
|
|
|
92 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
93 |
Public Sub CatchORA ( ByRef objOraSession )
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
If Err.Number <> 0 Then
|
|
|
97 |
|
|
|
98 |
If IsNull( sMsgSummary ) Then
|
|
|
99 |
sMsgSummary = GetORAErrDescription ( Err.Description )
|
|
|
100 |
sMsgDetails = Err.Description
|
|
|
101 |
End If
|
|
|
102 |
|
|
|
103 |
' Roll back DB transaction
|
|
|
104 |
objOraSession.RollBack
|
|
|
105 |
|
|
|
106 |
' Redirect to Message
|
|
|
107 |
If bErrorRedirect Then
|
|
|
108 |
Session( enumEXCEPTION_HANDLER_SESSION ) = sMsgSummary & SEPARATOR & sMsgDetails
|
|
|
109 |
Call OpenInWindow ( "messages/msgPleaseNote.asp" )
|
|
|
110 |
bIsDisplayed = TRUE
|
|
|
111 |
End If
|
|
|
112 |
|
|
|
113 |
Else
|
|
|
114 |
' Commit db transaction
|
|
|
115 |
objOraSession.CommitTrans
|
|
|
116 |
|
|
|
117 |
End If
|
|
|
118 |
|
|
|
119 |
Err.Clear
|
|
|
120 |
End Sub
|
|
|
121 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
122 |
Private Function GetORAErrDescription ( sErrMsg )
|
|
|
123 |
Dim tempArr, endOfMsg
|
|
|
124 |
|
|
|
125 |
' Example of ORAErr Description
|
|
|
126 |
' SQL execution error, ORA-20000: Duplicate Network Node name. ORA-06512: at "DM_DEV.PK_NETWORK_NODE", line 20 ORA-06512: at line 1
|
|
|
127 |
|
|
|
128 |
tempArr = Split ( sErrMsg, ":" ) ' Oracle error message is split with :
|
|
|
129 |
|
|
|
130 |
endOfMsg = InStr( tempArr(1), "ORA" )
|
|
|
131 |
|
|
|
132 |
If endOfMsg > 0 Then
|
|
|
133 |
GetORAErrDescription = Left( tempArr(1), endOfMsg - 1 )
|
|
|
134 |
|
|
|
135 |
Else
|
|
|
136 |
GetORAErrDescription = tempArr(1)
|
|
|
137 |
|
|
|
138 |
End If
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
End Function
|
|
|
142 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
143 |
Public Sub DisplayMessage ()
|
|
|
144 |
Dim msgTemplate
|
|
|
145 |
msgTemplate = ReadFile( APP_ROOT &"\scripts\note_style.html" )
|
|
|
146 |
msgTemplate = Replace( msgTemplate, "%WIDTH%", "100%" )
|
|
|
147 |
msgTemplate = Replace( msgTemplate, "%IMAGE%", "s_warning.gif" )
|
|
|
148 |
msgTemplate = Replace( msgTemplate, "%DIV_NAME%", "DIV_MESSAGE" )
|
|
|
149 |
msgTemplate = Replace( msgTemplate, "%NOTE%", sMsgSummary )
|
|
|
150 |
msgTemplate = Replace( msgTemplate, "%MESSAGE_DETAILS%", sMsgDetails )
|
|
|
151 |
|
|
|
152 |
Response.write msgTemplate
|
|
|
153 |
bIsDisplayed = TRUE
|
|
|
154 |
End Sub
|
|
|
155 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
156 |
Private Sub GetSessionMessages ()
|
|
|
157 |
Dim tempArr
|
|
|
158 |
If Session( enumEXCEPTION_HANDLER_SESSION ) <> "" OR NOT IsNull(Session( enumEXCEPTION_HANDLER_SESSION )) Then
|
|
|
159 |
tempArr = Split ( Session( enumEXCEPTION_HANDLER_SESSION ), SEPARATOR )
|
|
|
160 |
If UBound( tempArr ) > 0 Then
|
|
|
161 |
sMsgSummary = tempArr(0)
|
|
|
162 |
sMsgDetails = tempArr(1)
|
|
|
163 |
End If
|
|
|
164 |
|
|
|
165 |
Session( enumEXCEPTION_HANDLER_SESSION ) = NULL
|
|
|
166 |
|
|
|
167 |
End If
|
|
|
168 |
End Sub
|
|
|
169 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
170 |
Private Sub Class_Initialize()
|
|
|
171 |
'// Perform action on creation of object. e.g. Set myObj = New ThisClassName
|
|
|
172 |
SEPARATOR = "|SEPARATOR|"
|
|
|
173 |
|
|
|
174 |
sMsgSummary = NULL
|
|
|
175 |
bIsDisplayed = FALSE
|
|
|
176 |
bErrorRedirect = TRUE ' By Default On error redirect to error message page
|
|
|
177 |
|
|
|
178 |
Call GetSessionMessages ()
|
|
|
179 |
End Sub
|
|
|
180 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
181 |
Private Sub Class_Terminate()
|
|
|
182 |
'// Perform action on object disposal. e.g. Set myObj = Nothing
|
|
|
183 |
If NOT bIsDisplayed AND NOT IsNull(sMsgSummary) Then
|
|
|
184 |
Response.write ( sMsgSummary & "<br>" & sMsgDetails )
|
|
|
185 |
End If
|
|
|
186 |
End Sub
|
|
|
187 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
188 |
End Class
|
|
|
189 |
%>
|