Function Reference


_DebugCOMError

Sets, resets or queries the debug level for COM errors

#include <Debug.au3>
_DebugCOMError ( [$iComDebug = 1 [, $bExit = False]] )

Parameters

$iComDebug [optional] Debug level. Possible values are:
-1 - Return the current settings
 0 - Disable debugging
 1 - Enable debugging. Output the debug info (default)
$bExit [optional] True if the script must be terminated

Return Value

Success: 1 if $iComDebug = 0 or 1 and sets @extended to:
0 - The COM error handler is not initialized
1 - The COM error handler has been initialized
2 - The COM error handler was already active
3 - The COM error handler is already disabled
1 if $iComDebug = -1 and sets the @error flag and @extended to current setting:
@error = current Debug level
@extended = current script termination.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - $iComDebug is not an integer or < -1 or > 1
2 - The COM error handler is already set to another function (= not set by this function)
3 - _DebugSetup() did not run properly. Make sure _DebugSetup() ran properly before calling this function
4 - Installation of the custom error handler failed. @extended is set to the error code returned by ObjEvent()

Remarks

Before calling this function, _DebugSetup() must be called first to create the debug session.

Related

_DebugSetup

Example

#include <Debug.au3>
#include <MsgBoxConstants.au3>

_DebugSetup(Default, True, 1, Default, True) ; 1 = Write messages with timestamps to the Report Log Window

Example()

; Example
; Provoke a COM error and let _DebugCOMError display the error messages in the Report Log Window
Func Example()
        ; Create application object for the Microsoft Internet Explorer
        Local $oIE = ObjCreate("InternetExplorer.Application")
        If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "_DebugCOMError UDF", "Error creating a new IE application object." & _
                        @CRLF & "@error = " & @error & ", @extended = " & @extended)
        ; Set up the COM error handler to write error messages to the Report Log Window
        _DebugCOMError(1)
        ; Provoke a COM error. Function is unknown
        $oIE.xyz()
        If @error <> 0 Then Return MsgBox($MB_SYSTEMMODAL, "_DebugCOMError UDF", "Error occurred and handled." & _
                        @CRLF & "@error = " & @error)
        ; Close the IE
        $oIE.Quit()
        $oIE = 0
EndFunc   ;==>Example