pdaughe Posted July 31, 2007 Share Posted July 31, 2007 If you look at this thread:http://www.autoitscript.com/forum/index.ph...c=50240&hl=you see that I've been struggling with handling COM errors in AutoIt. If you have experienced the same, you may try what I found to be the solution:Simply by replacing the statement:ObjEvent ("AutoIt.Error", "Error_Handler")with$My_Error = ObjEvent ("AutoIt.Error", "Error_Handler")the error handler intercepts the COM error, as expected.Perhaps it's a requirement to save the object name, but it wasn't apparent.... Link to comment Share on other sites More sharing options...
ptrex Posted July 31, 2007 Share Posted July 31, 2007 @pdaugheIt's always been like that as far as I know.; Initialize error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")regardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 For some reason, even with this, the errors aren't caught in a compiled script.. Is there a way to catch the COM errors in a compiled script? Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 (edited) For some reason, even with this, the errors aren't caught in a compiled script.. Is there a way to catch the COM errors in a compiled script?It does ... can you tell us what the error is and can you show a snippet that has a problem ?Jos Edited September 11, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 (edited) Thanks for the fast respnse. Basically the error is caught if I run the script from SciTe, but not when it's compiled. The error is an email error (server not found) that I created just to test. Ok, the script is large, but here are the related lines: (compiled with 3.2.7.4) #include "Functions.au3" Global $oMyError = ObjEvent("AutoIt.Error", "COMErrFunc"), $oMyRet[2] . . . make a GUI with a titled window . . . make a second GUI that has a button that creates the COM error Functions.au3: Func COMErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) _DoLog("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @CRLF) SetError(1); something to check for when this function returns Return EndFunc;==>MyErrFunc Func _Dolog($text) ...some code that logs errors.. EndFunc see anything wrong? I can PM you the entire code (3100 lines) if you want. Edited September 11, 2007 by drlava Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 (edited) you didn't tell me what the error was you got ... Edited September 11, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 Sorry, COM Error with DOM! err.description is: The transport failed to connect to the server. err.widescription: (two boxes here, like some unicode out of range) err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: -1 err.source is: CDO.Message.1 err.helpfile is: err.helpcontext is: 0 Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 This indicates that the ErrorHandler does work .... Do you check for @error after com statements to see in the error handler kicked in ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 yes, @error is set, however COMErrFunc() is never called. When run from SciTe, COMErrFunc() is called and the error popup doesn't happen (preferred in this case). Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 (edited) yes, @error is set, however COMErrFunc() is never called.When run from SciTe, COMErrFunc() is called and the error popup doesn't happen (preferred in this case).I am confused: Where does the error you posted come from if there is no Error_Handler active ?One other question: Are there spaces infront of the #include statement ? Edited September 11, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 (edited) Windows? i don't know, but before I ever learned about COM error handling with AutoIt.Error, a dialog box would appear formatted just like above with the error. This is the default error handling I think, if there is no ObjEvent("AutoIt.Error" specified. nope no spaces. it goes like this: ;Compiled in Autoit V. 3.2.7.4 Best viewed with SciTE4AutoIt3 ;This version: 0.55 $Version='0.55' ; $TransformVersion='1.33' ;XML transform version $DTDVersion='1.34' ;XMLTV DTD version #include <Array.au3> #include <Date.au3> #include <string.au3> #include <GuiTab.au3> #include <GUIConstants.au3> #include <File.au3> #include "Functions.au3" #include "Functions_XML.au3" Edited September 11, 2007 by drlava Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 Windows? i don't know, but before I ever learned about COM error handling with AutoIt.Error, a dialog box would appear formatted just like above with the error. This is the default error handling I think, if there is no ObjEvent("AutoIt.Error" specified.did you see my EDIT?One other question: Are there spaces infront of the #include statement ?There was a bug in an earlier release that included files were missing in compiled script when the line contained leading spaces or tabs.. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 did you see my EDIT?There was a bug in an earlier release that included files were missing in compiled script when the line contained leading spaces or tabs..did you see my edit? I know they are being included, becuase other functions are beng called, no problem. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 Windows? i don't know, but before I ever learned about COM error handling with AutoIt.Error, a dialog box would appear formatted just like above with the error. This is the default error handling I think, if there is no ObjEvent("AutoIt.Error" specified.nope no spaces. it goes like this:;Compiled in Autoit V. 3.2.7.4 Best viewed with SciTE4AutoIt3;This version: 0.55$Version='0.55' ;$TransformVersion='1.33' ;XML transform version$DTDVersion='1.34' ;XMLTV DTD version#include <Array.au3>#include <Date.au3>#include <string.au3>#include <GuiTab.au3>#include <GUIConstants.au3>#include <File.au3>#include "Functions.au3"#include "Functions_XML.au3"Is there anyway you can take the SMTP email portion into a test script and replicate the problem ? (then post the script and include?)I will be offline in a couple of minutes but will have a look at it tomorrow when nobody else got to it by then...Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 Is there anyway you can take the SMTP email portion into a test script and replicate the problem ? (then post the script and include?)I will be offline in a couple of minutes but will have a look at it tomorrow when nobody else got to it by then...Jos I tried a simple script, even with external includes, but could not replicate. It seems to need the whole program, or at least some unknown part of it. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 11, 2007 Developers Share Posted September 11, 2007 I tried a simple script, even with external includes, but could not replicate. It seems to need the whole program, or at least some unknown part of it.well PM me the lot and tell me what to do to get it wrong and will try to look at it tomorrow..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drlava Posted September 11, 2007 Share Posted September 11, 2007 ok, thanks. I'll spend a few more minutes here adding a GUI to the test to see if maybe that's the special sauce. Link to comment Share on other sites More sharing options...
drlava Posted September 12, 2007 Share Posted September 12, 2007 Oops, ok one of the UDFs I was using was over-writing $oMyError wihtout me knowing it, and it happened in such a way that it would only over-write when run from compiled, so that's why it appeared to be breaking only then. Now that it's cleared up, things work well. thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now