Failing the build on JavaScript errors

Jan 26, 2010 at 4:11 PM

Hi all,

first of all - great project! Saved a lot of potential trouble and we do intend to use it!

Now, to the business...

If the compressor is used as a custom build task, and one of the JS files contains an error - the JavaScriptCompressor.Compress() throws an exception somewhere, which is caught in CompressorTask.cs:346 (I'm looking at .NET 3.5 version). It then logs the error and proceeds further. This results in a successfull build with 2 (or more) errors.

Now, wouldn't it be nice, if the build actually failed?

Suggestion: rethrow the exception, catch it inside CompressorTask.Execute(), and return false. This could also be param based (i.e. only if FailBuildOnError=true). There are alternative methods to this, I believe, too. In ideal world, you would also get a line in which JS error occured, though I haven't investigated how to achieve that.

Also, this may not just be yet another feature request, as I might be able to spend some company (or at least personal) time to make a patch - though I'd probably need more detailed instructions and guidelines in this case from you.