Jump to content

Error Handling


Brizz
 Share

Recommended Posts

I've put together a script that fills some forms in Internet Explorer. I'm a newb, so some of the stuff I'm saying may not be correct...but hopefully you can get the gist of it :)

Every once in a while, there's an error that pops up that red icon error box--that terminates the script. It's usually an Internet Explorer error...as a result of the page not loading, then it not being able to see the 'form', which a function that is called tries to see..

I did some looking, and it looks like there is Internet Explorer error handling.

However, I really just want to get this going...and don't know a whole bunch about error handling, or COM (have no idea...) (came up when searching for error handling).

I'd just like to take care of the problem ..quick and dirty. I'd like to restart the script if it encounters and error that normally terminates it.

Is there anyway, when Autoit runs into a 'fatal' error like this, that terminates the script, that I can simply have it run the script again as it exits?

Many thanks....

Link to comment
Share on other sites

Hi Brizz,

Doing a search of your topic, it's been found many times with the search feature or is listed as a non-descriptive topic.

Please do a search before posting new thread topics.

And please use descriptive topics so that others that do use the search feature may also find what they are seeking.

(You'll also find that using descriptive topics, will get people in your thread that know how to answer your questions, those same people ignore non-descriptive topics).

Thanks.

Link to comment
Share on other sites

  • Moderators

_IEErrorHandlerRegister ... Check that out and how to use it in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hi Brizz,

Doing a search of your topic, it's been found many times with the search feature or is listed as a non-descriptive topic.

Please do a search before posting new thread topics.

And please use descriptive topics so that others that do use the search feature may also find what they are seeking.

(You'll also find that using descriptive topics, will get people in your thread that know how to answer your questions, those same people ignore non-descriptive topics).

Thanks.

I did not search specifically on this site..but using Google, as I've had the most success with that route.

..and Smoke as I stated--I found the info regarding the internet Explorer error handler...I don't understand it all, and don't really want to make the time to right now. ...I want a quick dirty solution that just gets this going for me...right now. For example, do I have to create an error handler for every possible error? ..I do not know this.

I did some more searching using the search in the forum, and so far what I've come across is other threads where you tell people to do some more searching :). I've searched for "error handling" "error handling restart script". I do not know what else to search for besides this. As I know Internet Explorer already has error handling..but as I stated, I figured theres probably a quicker/dirtier way to do this.

So having said that, if someone reads this, and actually wants to help me based off my specific questions unique to what I am doing, it would be greatly appreciated.

I'm not really a programmer, but I have been able to put together a few scripts. So I do not know the proper terminology for some stuff, and do not know much about error handling in general. From what I've read you should have an error handler after something that could possibly cause an error.

From what I can gather, in my script it can occur in several different places throughout the script...and I want it to do the same thing on any fatal error that it encounters--restart the script.

I did some more searching in the help file, and decided to check out 'COM', since I didn't know what that means. I think I came across what I'm looking for...

It gives this example

An example:

 

Global $g_eventerror = 0; to be checked to know if com error occurs. Must be reset after handling.

$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 $g_eventerror 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 ) 

   $g_eventerror = 1; something to check for when this function returns 
Endfunc

...I do not have, or do not know, a specific line that the error could occur after. Could I just have the handler cover the whole script--then have the function re-run the script?

Does the handler suppress the dialog box that normally pops up?

Thank you for any help anyone is able to give... ..and I apologize if I'm too newb for the forum.

I am familiar with search--I'm not a newb to the internet >_<. Google usually answers most of my questions (as Google is a great search engine covering the forum too), as you can see I've only had two posts--I only ask if I really run across something I'm unsure of and can't find an answer to.

..Thanks.

[edit]

This may be solution to my problem...

If I used..........

_IEErrorHandlerRegister ("MyErrFunc")

could I just make MyErrFunc call my functions that I use to start my script--and it would do that on any IE errors?

Edited by Brizz
Link to comment
Share on other sites

  • Moderators

I did not search specifically on this site..but using Google, as I've had the most success with that route.

..and Smoke as I stated--I found the info regarding the internet Explorer error handler...I don't understand it all, and don't really want to make the time to right now. ...I want a quick dirty solution that just gets this going for me...right now. For example, do I have to create an error handler for every possible error? ..I do not know this.

I did some more searching using the search in the forum, and so far what I've come across is other threads where you tell people to do some more searching :). I've searched for "error handling" "error handling restart script". I do not know what else to search for besides this. As I know Internet Explorer already has error handling..but as I stated, I figured theres probably a quicker/dirtier way to do this.

So having said that, if someone reads this, and actually wants to help me based off my specific questions unique to what I am doing, it would be greatly appreciated.

I'm not really a programmer, but I have been able to put together a few scripts. So I do not know the proper terminology for some stuff, and do not know much about error handling in general. From what I've read you should have an error handler after something that could possibly cause an error.

From what I can gather, in my script it can occur in several different places throughout the script...and I want it to do the same thing on any fatal error that it encounters--restart the script.

I did some more searching in the help file, and decided to check out 'COM', since I didn't know what that means. I think I came across what I'm looking for...

It gives this example

An example:

 

Global $g_eventerror = 0; to be checked to know if com error occurs. Must be reset after handling.

$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 $g_eventerror 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 ) 

   $g_eventerror = 1; something to check for when this function returns 
Endfunc

...I do not have, or do not know, a specific line that the error could occur after. Could I just have the handler cover the whole script--then have the function re-run the script?

Does the handler suppress the dialog box that normally pops up?

Thank you for any help anyone is able to give... ..and I apologize if I'm too newb for the forum.

I am familiar with search--I'm not a newb to the internet >_<. Google usually answers most of my questions (as Google is a great search engine covering the forum too), as you can see I've only had two posts--I only ask if I really run across something I'm unsure of and can't find an answer to.

..Thanks.

[edit]

This may be solution to my problem...

If I used..........

_IEErrorHandlerRegister ("MyErrFunc")

could I just make MyErrFunc call my functions that I use to start my script--and it would do that on any IE errors?

You need to understand, that we're not here for your quick and dirty solutions. We help those that help themselves, and if that is telling you continue to search until you understand better, then that is what I/we do. You may not appreciate it at all now, and wish to be a sarcastic individual, however, in the long run, you not only learn how to search for your issues, but also learn how to interpret much faster what you are actually reading.

If you are only trying to get rid of the error, I gave the "simple" answer. You simply put it at the top of your script just like:

_IEErrorHandlerRegister()
; My code here

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

We help those that help themselves, and if that is telling you continue to search until you understand better, then that is what I/we do. You may not appreciate it at all now, and wish to be a sarcastic individual, however, in the long run, you not only learn how to search for your issues, but also learn how to interpret much faster what you are actually reading.

If you are only trying to get rid of the error, I gave the "simple" answer. You simply put it at the top of your script just like:

_IEErrorHandlerRegister()
; My code here

Yes, I am familiar with the 'better for the long term', and I agree...for the long term. However, in life we encounter certain scenarios where it would be best to just handle an issue quickly, if possible, to move onto the next part to get the 'whole picture' in better view...then come back and tweak things up. THEN when you have the time to dedicate to that issue, and are not working out of frustration, go back and do it 'properly'. At least for me personally, I find this approach keeps me motivated, and accomplishing more (learning more as I progress to the next part, sometimes even finding the answer to things I had left 'dirty'), --rather than getting stuck on issue for hours and hours.

It is a shame that forums in general have such a bad attitude about newbs to the forum who ask for help, particularly issues that have been answered before. Even though this board has over a HALF MILLION posts. Keep in mind that you have 13,000 posts, stuff that may seem like it has been answered over and over, probably seems familiar to you. The best I can do is search for terms that are familiar to me.

I would say some people come here for help to problems that they are having, and don't plan on becoming a member of the forum community with thousands upon thousands of posts, and therefore simply decide to ask their question after making a solid attempt to parse through the hundreds of thousands of posts that are here.

You said you 'help those who help themselves'. I clearly laid out everything that I had done, what I had search, and come across. I figured that the 'General Help and Support' forum would be a good place to head and present my case (including what I had already done and terms I had searched for).

And there was no part in any of my posts that I was being sarcastic.

I said all of that, because I felt that you had an unnecessary condescending attitude towards me. BUT, I understand where you are coming from completely, so it's all good. I just wanted to lay out my point of view :)

...

I appreciate the help, exactly what I needed.

Link to comment
Share on other sites

  • Moderators

Yes, I am familiar with the 'better for the long term', and I agree...for the long term. However, in life we encounter certain scenarios where it would be best to just handle an issue quickly, if possible, to move onto the next part to get the 'whole picture' in better view...then come back and tweak things up. THEN when you have the time to dedicate to that issue, and are not working out of frustration, go back and do it 'properly'. At least for me personally, I find this approach keeps me motivated, and accomplishing more (learning more as I progress to the next part, sometimes even finding the answer to things I had left 'dirty'), --rather than getting stuck on issue for hours and hours.

It is a shame that forums in general have such a bad attitude about newbs to the forum who ask for help, particularly issues that have been answered before. Even though this board has over a HALF MILLION posts. Keep in mind that you have 13,000 posts, stuff that may seem like it has been answered over and over, probably seems familiar to you. The best I can do is search for terms that are familiar to me.

I would say some people come here for help to problems that they are having, and don't plan on becoming a member of the forum community with thousands upon thousands of posts, and therefore simply decide to ask their question after making a solid attempt to parse through the hundreds of thousands of posts that are here.

You said you 'help those who help themselves'. I clearly laid out everything that I had done, what I had search, and come across. I figured that the 'General Help and Support' forum would be a good place to head and present my case (including what I had already done and terms I had searched for).

And there was no part in any of my posts that I was being sarcastic.

I said all of that, because I felt that you had an unnecessary condescending attitude towards me. BUT, I understand where you are coming from completely, so it's all good. I just wanted to lay out my point of view :)

...

I appreciate the help, exactly what I needed.

In your first post

I did some looking, and it looks like there is Internet Explorer error handling.

My first post:

_IEErrorHandlerRegister ... Check that out and how to use it in the help file.

I was giving you the exact thing to look for. The reference to the help file was because there was actually an example on how to use it rather than me having to write one myself.

; Register a customer error handler
_IEErrorHandlerRegister ("MyErrFunc")
; Do something
; Deregister the customer error handler
_IEErrorHandlerDeregister ()
; Do something else
; Register the default IE.au3 COM Error Handler
_IEErrorHandlerRegister ()
; Do more work
Look at the last example there and the comment under.

I'm sorry if I assumed it was fairly easy to understand with an example.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I said in my first post I did not want to deal with IE error handler, and you responded with that anyways, with no comment. I only tried it out after your other post saying that it would take care of it.

No you did not say you didn't want to deal with it. You asked if there was a way to work around it because you weren't familiar with COM error handling (which a lot of people on this forum are not). You made a mention that there "looked" like there was IE error handling, but made no mention of what you were speaking about. I guess we were left to assume you actually knew that that specific function existed.

The bottom line. You did not actually state "clear" enough what it is you had done to try and correct the issue, and or did not explain well enough a solution you would like with things you would not like to have within that solution.

My 13k posts for the majority, are helping poor souls such as yourself because I have been there done that.

I'll try to spend 7-8hours of my day hanging out on the forum, then some day I'll be able to talk down to the people that ask for help :)

If you make it that long >_<

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You made a mention that there "looked" like there was IE error handling, but made no mention of what you were speaking about. I guess we were left to assume you actually knew that that specific function existed.

It took me a few days after getting AutoIT before I finally decided to look at the help file. Normally I avoid help files..because to me..a lot of times they don't seem that helpful.

Once I opened it, I realized how awesome AutoIt was. Yes, I'm familiar with the functions.

So yea..I knew that that function existed.

AutoIT is awesome, and the documentation that comes with it is awesome. I've been able to create some really cool stuff...one of which (that this particular thing got me going on..which is why I wanted a quick solution), is in a very large part responsible for making me several thousand per month.

I'm done with the little back and forth. I will do my best to explain myself as clear as possible next time. I was in a rush, and really wasn't sure what I was talking about. I should have read about COM first, because that pointed me in the right direction for understanding some things. The documentation really is amazing...

peace :)

Edited by Brizz
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...