Spence Posted January 7, 2010 Share Posted January 7, 2010 Hi everyone, I'm fairly new with AutoIT but not to programming, I've managed to create some good scripts for my job however I've always struggled with Error Control / Handling. I've mainly made TCP event driven apps which have over 200 client connections and at times I get errors and the client just stops - ideally I'd like to handle these errors and be able to recover or in a worst case scenario, re-start the application. My issue is that whatever I try to "catch" errors, it never seems to work Here's a very simple test of error handling which, I believe should work - but doesn't: ; Error Control Test ; Wanting to handle basic errors Global $EControl = ObjEvent("AutoIt.Error", "ErrorControl") Dim $VarA Dim $VarD[1] ; Create undefined variable error $VarA = $VarB & $VarC ; Create undimensioned variable error $VarD[5] = "Testing" Func ErrorControl() ; Intercept Error Message ConsoleWriteError("Error Caught: " & $EControl.description & " (" & $EControl.number & ")" & @CRLF) return 0 EndFunc Neither "errors" are caught and just end up quitting the application. Any ideas what I'm doing wrong? Spence Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 7, 2010 Share Posted January 7, 2010 Catching COM errors can't help you when something outside COM breaks down, so forget what you just wrote. You should have a "parent" script that Run() the real one with the /ErrorStdOut, and then catch error that way. I think it's read by StdoutRead but don't know, I haven't actually done this myself. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Spence Posted January 7, 2010 Author Share Posted January 7, 2010 Thank you - I hadn't thought about doing it that way! As the arrays in my scripts can be redimensioned by events, even with a locking variable I've not been able to get around these kinds of errors. But this is the perfect solution 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