zackrspv Posted March 28, 2008 Share Posted March 28, 2008 Hi! Since i've been having fun writing some rather function heavy scripts, I was wondering how it would be possible to catch global errors in the script. For example, sometimes, when the script runs, it may error out saying '-1, the requested action with this object has failed'; as I do not know where it is erroring out, especially when one of my users is using the program, it would be nice to have some sort of error check/handle for the entire script instead of having to constantly check @error = 0 or 1 lol Secondly, is there a way to give more DETAIL on what the error was so that the program doesn't close, or that I can write an error handle routine that catches all global errors in the script to help the client out more? Thanks! -_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë. Link to comment Share on other sites More sharing options...
monoceres Posted March 28, 2008 Share Posted March 28, 2008 Since you mentioned object I assume that you use some kind of COM, in that case you can register you rown COM error function like this (Copied from the helpfile): $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler ; Performing a deliberate failure here (object does not exist) $oIE = ObjCreate("InternetExplorer.Application") $oIE.visible = 1 $oIE.bogus if @error then Msgbox(0,"","the previous line got an error.") Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1) ; something to check for when this function returns Endfunc Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
zackrspv Posted March 28, 2008 Author Share Posted March 28, 2008 Since you mentioned object I assume that you use some kind of COM, in that case you can register you rown COM error function like this (Copied from the helpfile): $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler ; Performing a deliberate failure here (object does not exist) $oIE = ObjCreate("InternetExplorer.Application") $oIE.visible = 1 $oIE.bogus if @error then Msgbox(0,"","the previous line got an error.") Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1) ; something to check for when this function returns EndfuncoÝ÷ Ûú®¢×ëZºÚ"µÍKIÍÈQK]LÈËLHØ[ÈÛH[Ý[Û[[[Ý[Û×ÒQRÓØKØ[ÝYÚÝ[[Ü[Ø[ÝÓÓHÜÈ ÙHÒQQÜ[YÚÝ HÈYÚÝHÙÜ[ If i remove the code above i get no error. When i register my IEErrorHandlerRegister, i get no issues. But i don't want to just trap _IE errors; i want to be able to trap any error that auto.it throws out to a user; esp those where it wouldn't work properly on their system (admin rights, etc). Hence, I need to figure out a global error handler. -_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë. 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