'********************************************************************
'* Function CommonErrorHandler()
'*
'* Author: NetworkAdminKB.com
'* Created: 2007-01-02
'* Modified: 2007-01-02
'*
'* Purpose: Displays Common Error Information, plus a given string.
'* Return True if an error occured, to allow further error
'* handling at the calling procedure.
'*
'* Input: strText: A string of Text to be printed that completes
'* the sentence "An error occurred ..."
'* strProcName: The calling prodedure name for debug purposes.
'* intError: The errorlevel code to return when exiting. (Optional)
'* blnQuit: A boolean value that incates to quit the script or not.
'* True = Quit Script
'* False = Continue
'*
'* Output: Returns a Boolean indicating if and error occured.
'* True = An error occurred
'* False = No error occurred
'*
'* Notes: Clears the error before returning.
'*
'* Changes:
'********************************************************************
Function CommonErrorHandler(ByVal strText, ByVal strProcName, ByVal intError, _
ByVal blnQuit)
'Version: 1.0 2007-01-02
Dim strError, strNow, strDesc
CommonErrorHandler = False
If Err.Number <> 0 Then
If IsEmpty(Err.Description) Or Err.Description = "" Then
strDesc = "Type 'Net Helmsg " & (Err.Number - &H80070000) & _
"' for more information"
Else
strDesc = Err.Description
End If 'IsEmpty(Err.Description) Or Err.Description = ""
strNow = Now
strError = strNow & ": An error occurred " & strText & vbCrLf
strError = strError & Space(Len(strNow)+2) & "0x" & Hex(Err.Number) & _
" - " & strDesc & vbCrLF
strError = strError & Space(Len(strNow)+2) & "Procedure: " & strProcName
WScript.Echo strError
If blnQuit Then
WScript.Quit(intError)
End If 'blnQuit
CommonErrorHandler = True
End If 'Err.Number <> 0
Err.Clear
End Function 'CommonErrorHandler
Article ID: 376, Created On: 9/25/2011, Modified: 9/25/2011