Run a list of rules, but stop if any one of them throws an error

Run a list of rules, but stop if any one of them throws an error

Stephan.Osterhaus
Contributor Contributor
261 Views
2 Replies
Message 1 of 3

Run a list of rules, but stop if any one of them throws an error

Stephan.Osterhaus
Contributor
Contributor

Hey all, I have a list of rules that usually run sequentially for a model either through a script that simply calls them all in order one after another or the user manually running each one and verifying that the output of each was complete and correct. I want to add some error handling to that script that calls all rules in a row to actually check if the rule ran successfully. Currently if one fails it tries to run the next rule, which fails even harder, and that continues down the line usually resulting in having to load a backup. 

 

Anyone know of a good way to do this?

0 Likes
Accepted solutions (1)
262 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Stephan.Osterhaus.  Yes...sort of.  The iLogic methods used to run rules are actually Functions, which means that they are a routine that is meant to return a value.  They will usually return an Integer.  I believe that Integer will be a 0 (zero) or a 1, depending on if the rule ran successfully.  And I believe it is supposed to return a zero, if it ran successfully.  This is not documented very well, but here is one link that actually mentions this.

IiLogicAutomation.RunExternalRule Method 

 

PS.  Getting a zero may not necessarily mean that everything in the rule went according to your plan, but probably more like:  the rule was found, and it was able to run the rule without any major rule stopping Exceptions being thrown.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Stephan.Osterhaus
Contributor
Contributor
I got a -1 on error and 0 on successful run. TYVM, I didn't realize it was technically a function but it makes sense.