Subversion Repositories DevTools

Rev

Rev 119 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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