How to generate an action error in BeforeAction

Hi,

I tried to generate some compact code but now I am stucked and like to have some new ideas.

The starting point is a variable called "PatchFiles" which contains some lines like 'crq\main.cpp=Patches\crq\main_2234.cpp'. These lines describe, which files should be overwritten by special file versions.

I started with List-Iterator-Action and a BeforeAction which gets line by line with a regular expression "(\S+)". The Iterator-Action calls a SourceSafe-Action. Now I extract in the BeforeAction the file name with a the next regular expression ".+=(\S+)". In case the line is corrupted I like to stop the build process, but how?

Thanks!

Christian

Hi Christian,

You're correct in noting that it's hard to fail an action from the BeforeAction script (although it's easy to skip the action.) I can think of two options:

1) Create a Run Script action and put the script in the OnExecute script event. Then, if there's an error you can use Action.SendLogMessage() to log it and set the ActionResult parameter to false in order to fail the action. This is what I would recommend.

2) Throw an exception, ie throw "Error"; or Err.Raise. The action will fail with a script error. If the script debugger is enabled and you're using a manually executed build, then you'll see the script debugger window before the action fails. This is messy, avoid it if you can.

Regard,

Angus

Hi Angus,

thanks for your help. I tried (1) but I did not liked it. So I removed the Run-Script-Action and put the script into the AfterAction of the List-Iterator-Action. It took me quite some tries/time but now it is working the way I like it.

Thanks.
Regards,

Christian

Hi Christian,

I’m glad you got it working.

Regards,

Angus