Hello, I'm trying to have a more transparent behaviour when trapping COM errors. This means that I want a call to a COM object to map through to something I can easily check, preferably the @error variable. The example in ObjEvent uses "$g_eventerror = 1" to pass the error back to the script. But that is not so transparent because it needs to be reset every time before performing a potentially error-generating COM call. I also see a lot of SetError(1) at the end of COM scripts, but when I print @error after the COM call, it seems to be set to the COM error, no matter what is written in the error handler. This behaviour would actually be exactly what I need, except that the @error doesn't get reset by the COM call itself, so e.g. $oShell = ObjCreate("shell.application")
_DebugReport(@error & " " & @extended)
$oshell.open("D:")
_DebugReport(@error & " " & @extended)
$oshell.open ; missing parameter!
_DebugReport(@error & " " & @extended)
$oshell.open("c:")
_DebugReport(@error & " " & @extended)will set the @error at the open call without parameters, but @error remains set from there on, even after the next successful call. So it would be necessary to reset it manually again just like $g_eventerror. In some scripts I see attempts to return 0 from the error handler as well. So my questions are: Is there a specification about if and what the error handler should return and SetError()?Is there a best practice of how to pass caught COM errors into the script for handling, that is as transparent and natural as possible (no preparation, preferably just mapped into @error)?Thanks in advance!