Let NSIS return an error string
I have another idea for NSIS. What if you made a variable like:
$ERROR$
which contains the Error message when an error has occured. This could be used in messageboxes, but cannot be changed by the script.