cmarchand / gaulois-pipe

A XSLT pipelining solution
Mozilla Public License 2.0
9 stars 4 forks source link

Gaulois raise Exception InvalidSyntax when folder does not exists #37

Open karrayhamdi opened 6 years ago

karrayhamdi commented 6 years ago

Hi,

when i run a gaulois pipe on an non existing folder source, il get the following Exception :

Caused by: fr.efl.chaine.xslt.InvalidSyntaxException: D:\data\output\prepare is not a valid directory at fr.efl.chaine.xslt.config.ConfigUtil.buildFolderContent(ConfigUtil.java:503) at fr.efl.chaine.xslt.config.ConfigUtil.buildSources(ConfigUtil.java:282) at fr.efl.chaine.xslt.config.ConfigUtil.buildConfig(ConfigUtil.java:186) at com.processing.step.GauloisPipeStep.run(GauloisPipeStep.java:93) ... 8 more The syntax is correct. I think the best way is simply to consider 0 file as source, with no exception thrown .

For example, i run 2 gaulois, the first one for filtring files and the second one to do some thing else with filtred files. If all files are filtred on the first gaulois pipe, my seconf gaulois pipe raise an Exception.

thanks

cmarchand commented 6 years ago

I think raising an exception to user is a good thing ; hence, user knows he has given a wrong configuration. If no exception was raised, he couldn't know he made a mistake, and can only think there is no file.

So, my opinion is we should keep the current behavior.

But, you are right, we should also be tolerant, for the case you mention.

What about adding an attribute to precise the behavior ? Something like :

    <sources>
        <folder href="..." recurse="true" pattern=".*\.xml" raiseFnfEx="false"/>
    </sources>

@raiseFnfEx has a default value of true, and if true, has the current behavior ; if false, FileNotFoundException is not raised, and 0 files are found.

What's your feeling ?