View Full Version : on error: increment my_overall_error_counter
andrelernhart
08-24-2014, 12:03 PM
Hi all,
In a quite complex script, I have to know if any of the actions failed, e.g. some files must be patched but at least 1 file was not found or was not a valid candidate.
If any action failed, I have to lauch the "Smart Rollback" in order not to leave an inconsistent system.
Since I also call some .exe/.dll in my script, I'm working with a "My_Overall_Error_Counter" which triggers the "Smart Rollback" coz SB cannot know by itself if this "Run Program" action was succesful or not.
Is there a way to implement an "Increment My_Overall_Error_Counter by 1 IF any %_SB_ERRORCODE% is not 0" ?
Next challenge for Friedrich... :-)
Thanks in advance for your time,
regards André
linder
08-25-2014, 12:48 AM
Hi André,
Just create a custom runtime variable, e.g. %MY_OVERALL_ERROR_COUNTER%. Then, if an action "fails" (depends on the functions return value and your interpretation of that specific value), increment the counter by 1.
Friedrich
andrelernhart
08-27-2014, 11:02 AM
Hi Friedrich,
sorry for late reply.
Thanks for your suggestion - that's exactly what I'm currently doing.
But...
What I was looking for is a way to avoid the need to manually (say, using the script editor) catching the errors, because the final user of the installers/update-installers is an incredible genius in his business domain but definitely an absolute non-techie with a unbeatable talent to mess up scripts... every time he adds files to be added/patched, he is urged to add the ALLOVERALL_ERROR catcher section to those files. This will end in a desaster, I'm sure.
So, please consider to add this as a feature request:
WHILE <error-catcher-block> BEGIN
... IF ERROR_RESULT (execute an action) <> No_ERROR then <increment value by 1 to %_my_defined_OVERALL_ERROR_COUNTER%>
END <error-catcher-block>
Possible? Does it make sense or is there a more clever way?
I guess the what's "NO_ERROR" part is the tricky part, referring to some posts related to the topic I checked before...
thanks in advance, highly appreciated!
best regards, André
linder
08-28-2014, 12:51 AM
André,
Possible? Does it make sense or is there a more clever way?
No. Unfortunately, this is impossible. "Why?", do I hear you ask? ;) Because only the developer of the install script (or any other application) can interpret the return value of a function and can decide if it is an error or not.
For example, you call an external MSI installer and it returns Error Code 3010. But it should return 0 if the action completed successfully. So what does it mean? Do you have to rollback in this case or not? The compiler is not a mind reading machine and so can't decide on its own what to do. Error Code 3010 means that a restart is required to complete the external install. This message is indicative of a success. But this does not include installs where the ForceReboot action is run. It's impossible to handle this with a simple "overall error counter". When you catch Error Code 3010, do you have continue with the install and reboot at the end of the setup or do you have to reboot immediately and let the SB install continue at restart? Only you know. Or another example. You call a Windows API from within your install. If the Error Code is 0, does it mean the function succeeded or failed? Well, it depends on the specific function. You have to check MSDN (or the documentation of the 3rd-party product) and decide what to do with the return code.
Do you see what I mean ;) Only YOU (the developer of the application) can decide what to do.
Friedrich
andrelernhart
08-29-2014, 03:32 AM
Friedrich,
thanks for your time.
I completely agree that for running external apps (like an .exe or .dll), only you know how to interprete the return codes. I have the "Execute Programs" section under my control, no problem at all.
I was referring to the "Install Files" section. I experienced a strange behavior: when a to-be-patched file is not a valid candidate, SB reports it and terminates the installer. OK so far since I did not want to ignore this fact ("Skip" not checked). After the final screen with "... was not successful...", a popup asks if I want to rollback the changes. If I hit "No", the offending to-be-patched file remains where it was. If I hit yes, the file is removed... this is not what I need.
Sneeking around I found the "Set Delayed File Install" feature, and this does exactly what I want: it protects the existing installation from getting messed up if something gets wrong since it checks first if the to-be-patched files are there and that they are valid candidates.
André
linder
08-29-2014, 04:28 AM
André,
You are doing it absolutely correct now !!! :)
Friedrich
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.