Automating QTP Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
General Function - Err (Error Handler)This function handles errors and writes details of the error to the Application Event Log using the function Log Error. Download it Here (right-click and then save target as). (NOTE - you can just cut & paste from below, but the formatting will have multiple spaces instead of tabs).
'=========================================================================
Sub zErr(sApp, sMod, iLine, oErr) 'General purpose error handler 'Usage: 'If Err <> 0 Then Call zErr(sApp,sMod,iLine,Err) 'Where: 'sApp = a string identifying the application 'sMod = a string identifying the function or sub in which the error occurred 'iLine = the line number on which the error occurred 'Err = The Error object Dim iErr, sErrDesc, sErrSrce 'Store the details from the error object iErr = oErr.Number sErrDesc = oErr.Description sErrSrce = oErr.Source 'Reset the error object Err.Clear 'Log the Error details to the event log Call zGen_LogError(sApp, sMod, iLine, iErr, sErrDesc, sErrSrce) 'Put more error handling code here if required End Sub '========================================================================= |