Archive: Nullsoft Error Handling


Discussion on Nullsoft Error Handling
I was hoping to start a discussion on error handling. I have been using nullsoft for quite some time and still find it quite difficult, if not impossible, to determine what causes some errors. I am interested in how others are handling errors and whether or not they feel the error handling in nullsoft lacking. Mostly, I would love to be able to capture the windows error(number or message) for errors. Some examples of problems I have had are:


I agree that error handling should be beefed up. Making your installer easy to troubleshoot is i feel an important aspect to consider while coding your installer. A suggestion would be able to set a type of error rather than a generic one. Kind of like a sudo exception. Then you could check to see if FileNotFoundError was set.

For my current error handling techniques, I include a detailedprint in the functions or macros I build to declare problems. An example would be:


StrCpy $R0 "c:\test\file.txt"
IfFileExists $R0 FileExists FileNotExists

FileExists:


FileNotExists:
detailprint 'Error: $R0 does not exist.'


Building this into my macros at least gives me some type of clue when it fails.

Also, to centralize my error catching and notification, I created a macro that checks if errors were set and prints a specified message in the installer console or a messagebox.

End of discussion?


I guess it isn't that important to anybody.


Re: Discussion on Nullsoft Error Handling

Originally posted by slloyd
I was hoping to start a discussion on error handling.
I'm glad you did! Pity it didn't get further.

Mostly, I would love to be able to capture the windows error(number or message) for errors.
I agree. It would be very nice to have a $ERROR variable that could be checked just as one checks errno in C, or a GetLastError function, and some way to return a textual error message based on this (in the local language, of course).

It might also be nice to have some sort of ON ERROR construct (as in Basic), but I'm not sure it wold be easy to get agreement on the most useful semantics for that :)

error handling
I am so surprised and disappointed to know taht NSIS does not have a useful error handling mechanism.
Hopefully in the next version, NSIS adds this feature.
Otherwise, we will keep on guessing on errors :(


Or even better, have a callback function that we can set up that NSIS will call when it detects an error during the install of files.

We have lots of .On* functions, why not .OnError where it sends us the filename, location where it was to be installed, filesize. We can parse it, determine if we care about it or not, and send back some sort of code, like "IGNORE" or "RETRY" to tell NSIS what to do about the error.