# ComObjError() [AHK_L 53+]

Enables or disables notification of COM errors.

    Enabled := ComObjError(Enable)

## Parameters

Enable

  A boolean value (true or false). Optional.

Enabled

  [v1.0.91+]: Receives the setting which was in effect before the function was called.

## General Remarks

Notification of COM errors is enabled by default.

COM errors may be raised by ComObjCreate(), ComObjGet(), ComObjActive(), ComObjConnect(), ComObjQuery() (if an invalid pointer is detected) or by a method or property of a COM object. Raising a COM error causes one of the following outcomes:

Setting | Outcome
--- | ---
0 (disabled) | The function, method or property returns a default value (typically an empty string), without showing an error dialog.
1 (enabled) | If there is an active Try block, an exception is thrown. Otherwise: An error dialog is shown, giving the user the option to continue the script. If the user chooses "Yes", the function, method or property returns a default value (typically an empty string) and the script continues. Otherwise, the script exits.

After accessing a COM object, A_LastError contains the HRESULT code returned by the COM object's IDispatch::Invoke function. The script may consult A_LastError within a Catch block or after the method or property returns, provided that `ComObjError(false)` has been used or the user did not choose to exit the script.

## Related

ComObjCreate(), ComObjGet(), ComObjActive(), ComObjConnect(), ComObjQuery()