Hi Dojo,
Can I get some more information on how this method is handled in an automation script?
engine.ExitSuccess("reason");
I was using this code inside an Application package install script, expecting that the script would finish successfully after exiting this way.
Instead the installer gave me the failure state with following message:
Looking at the method documentation, it mentions this method is actually throwing an "ScriptAbortException". And that I should take this into account and probably handle/catch this myself.
How do I properly handle the ScriptAbortException, to differentiate between the success & fail types?
Right now, I added something like this:
I feel the above could probably improve. Any feedback is welcome!
Thank you!
Hi Miguel, Yes I also saw that one as well, after reading Floris’s answer I indeed noticed that the method documentation states there is an “ScriptAbortException” thrown that you should handle. Still it’s not clear how I can determine whether its a success of fail abort-exception…
Hi Thijs,
I'm afraid there is no other way to distinguish between a fail and success ScriptAbortException. Both ExitSuccess() and ExitFail() only seem to set the message in the exception, so there is no other property you could check.
I actually ran into a similar problem not so long ago. An alternative approach (especially if other code refactors are too challenging) is throwing your own 'SuccessException' instead of calling ExitSuccess and use that as some kind of (expensive) goto. You could then catch that exception in the Run method of the script, and handle it accordingly.
Hi Tom, thanks for both clarifying and providing a code suggestion. In the end I don’t think I’ll go with throwing a custom exception, I think I’ll just refactor a bit and use a simple condition to execute remaining piece of code, or not. Since the code is not too long and complex, that way I remain keeping it simple. Thanks again
That’s indeed a better solution than (ab)using exceptions for this.
Hi Thijs,
I remember I saw already a similar question:
https://community.dataminer.services/question/interactive-automation-script
The answer states that the exception is expected, but there are no comments about how to make the distinction.