Archive: Catching an error


Catching an error
Is there a way to catch exceptions in NSIS?

My problem is the following:

I want to write to a file but first I want to ensure that it is not currently open by some other operation.

If it is, I want to place a MessageBox on the screen, inform the user that it cannot be written to and then prompt them to continue or not with the installation.

Thanks.


you can check if >> FileOpen $0 "c:\foo" a << fails


Use FileOpen as Anders suggests with a ClearErrors before hand followed by IfErrors (or ${If} ${Errors} ... ${EndIf} if you use LogicLib).

Stu


its less work to check if $0 (outvar) is empty ;)