onError - Multiple macros, is there a way to have a global onerror set once?

I have a set of macros that scrape a desktop application, I opened an earlier post about reliability but I think in the meantime I worked out that the way to go is onerror but I have a question about onerror.

I’m looking at DemoIfElse and in there, the onError is set and at the bottom of the function is the code. I have 2 questions. Do I need to set the onError in every function? If I can set it just once, can there be a global label section just set once, or do I need to have the code (I plan on just run’ing a function) at the bottom of every function?

Is there a way to have a global onerror, so I just set it once and it works everywhere or do you need to put the onerror code in each function?

The best error handling really depends on what kind of errors you want to catch.

  • Web browsing errors? (Page does not load etc)

  • Computer vision image not found errors?

  • OCR errors?

There is no web browsing, it’s scraping a desktop program and I don’t use the internal OCR.

It is usually on vision, I already have some pre checks but it wouldn’t be feasible to do it on all (I do a lot) and it wouldn’t work fully either, as if it’s errored, it’s usually because something weird has happened and it’s nowhere near the screen with the image it’s trying to press.

Ok, understand. And what should the RPA software do in this case? Run a certain set of commands to fix the situation? Or simply start from line1?

I was thinking of having a function that tried to get back to the screen it can start from again. So it would use vision to check the page heading and then step back to the list of records page, then start again.


It would be great if I could have an answer to the initial question of if I can setup the onerror just once, even though I’m going through many functions. This got lost in questions that were interesting but irrelevant.

I have a set of functions where any one of them can fail, because for example the network going down briefly. I could put onerror at the start of each function and code like in “DemoIfElse” at the end of each function that run’s the same function but I have tried to be modular, so I have LOTS of functions, so it would be a lot of work and duplication of code.

A Yes / No on this would be great on this.