Rev 13 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%'============================================================='//'// Exception Handler'//'// version: 1.4'// last modified: 20-Jul-2004 14:17 by Sasha Vukovic'=============================================================%><%'------------- GLOBALS --------------Const enumEXCEPTION_HANDLER_SESSION = "DM_EXCEPTION_HANDLER"'------------------------------------%><%Class ExceptionHandlerPrivate sMsgSummaryPrivate sMsgDetailsPrivate bIsDisplayedPrivate bErrorRedirectPrivate SEPARATORPublic Property Let ErrorRedirect ( bVal )bErrorRedirect = bValSession( enumEXCEPTION_HANDLER_SESSION ) = NULL ' Clear message session variableEnd PropertyPublic Property Get MessageSummaryMessageSummary = sMsgSummarybIsDisplayed = TRUEEnd PropertyPublic Property Get MessageDetailsMessageDetails = sMsgDetailsbIsDisplayed = TRUEEnd Property'-----------------------------------------------------------------------------------------------------------------Public Sub LogAction ( nUserId, nEvent, sMethod, sActionScript, sDescription, ByRef OraDatabase )OraDatabase.ExecuteSQL _"BEGIN pk_Utils.Log_Action ( "&_nUserId &","&_nEvent &","&_"'"& sMethod &"',"&_"'"& sActionScript &"',"&_"'"& sDescription &"'"&_" ); "&_"END;"End Sub'-----------------------------------------------------------------------------------------------------------------Public Function Finally ()If IsNull( sMsgSummary ) OR bErrorRedirect ThenFinally = TRUEElseFinally = FALSEEnd IfEnd Function'-----------------------------------------------------------------------------------------------------------------Public Sub Try ()Err.ClearEnd Sub'-----------------------------------------------------------------------------------------------------------------Public Sub Catch ()If Err.Number <> 0 ThenIf IsNull( sMsgSummary ) ThensMsgSummary = Err.SourcesMsgDetails = Err.DescriptionEnd If' Redirect to MessageIf bErrorRedirect ThenSession( enumEXCEPTION_HANDLER_SESSION ) = sMsgSummary & SEPARATOR & sMsgDetailsCall OpenInWindow ( "messages/msgPleaseNote.asp" )bIsDisplayed = TRUEEnd IfEnd IfErr.ClearEnd Sub'-----------------------------------------------------------------------------------------------------------------Public Sub TryORA ( ByRef objOraSession )Err.Clear' Begin DB transactionobjOraSession.BeginTransEnd Sub'-----------------------------------------------------------------------------------------------------------------Public Sub CatchORA ( ByRef objOraSession )If Err.Number <> 0 ThenIf IsNull( sMsgSummary ) ThensMsgSummary = GetORAErrDescription ( Err.Description )sMsgDetails = Err.DescriptionEnd If' Roll back DB transactionobjOraSession.RollBack' Redirect to MessageIf bErrorRedirect ThenSession( enumEXCEPTION_HANDLER_SESSION ) = sMsgSummary & SEPARATOR & sMsgDetailsCall OpenInWindow ( "messages/msgPleaseNote.asp" )bIsDisplayed = TRUEEnd IfElse' Commit db transactionobjOraSession.CommitTransEnd IfErr.ClearEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Function GetORAErrDescription ( sErrMsg )Dim tempArr, endOfMsg' Example of ORAErr Description' SQL execution error, ORA-20000: Duplicate Network Node name. ORA-06512: at "DM_DEV.PK_NETWORK_NODE", line 20 ORA-06512: at line 1tempArr = Split ( sErrMsg, ":" ) ' Oracle error message is split with :endOfMsg = InStr( tempArr(1), "ORA" )If endOfMsg > 0 ThenGetORAErrDescription = Left( tempArr(1), endOfMsg - 1 )ElseGetORAErrDescription = tempArr(1)End IfEnd Function'-----------------------------------------------------------------------------------------------------------------Public Sub DisplayMessage ()Dim msgTemplatemsgTemplate = ReadFile( APP_ROOT &"\scripts\note_style.html" )msgTemplate = Replace( msgTemplate, "%WIDTH%", "100%" )msgTemplate = Replace( msgTemplate, "%IMAGE%", "s_warning.gif" )msgTemplate = Replace( msgTemplate, "%DIV_NAME%", "DIV_MESSAGE" )msgTemplate = Replace( msgTemplate, "%NOTE%", sMsgSummary )msgTemplate = Replace( msgTemplate, "%MESSAGE_DETAILS%", sMsgDetails )Response.write msgTemplatebIsDisplayed = TRUEEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Sub GetSessionMessages ()Dim tempArrIf Session( enumEXCEPTION_HANDLER_SESSION ) <> "" OR NOT IsNull(Session( enumEXCEPTION_HANDLER_SESSION )) ThentempArr = Split ( Session( enumEXCEPTION_HANDLER_SESSION ), SEPARATOR )If UBound( tempArr ) > 0 ThensMsgSummary = tempArr(0)sMsgDetails = tempArr(1)End IfSession( enumEXCEPTION_HANDLER_SESSION ) = NULLEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Initialize()'// Perform action on creation of object. e.g. Set myObj = New ThisClassNameSEPARATOR = "|SEPARATOR|"sMsgSummary = NULLbIsDisplayed = FALSEbErrorRedirect = TRUE ' By Default On error redirect to error message pageCall GetSessionMessages ()End Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Terminate()'// Perform action on object disposal. e.g. Set myObj = NothingIf NOT bIsDisplayed AND NOT IsNull(sMsgSummary) ThenResponse.write ( sMsgSummary & "<br>" & sMsgDetails )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------End Class%>