CAMEL-9549 - Improvement of error messages when compiling the schema
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/441e5b57 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/441e5b57 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/441e5b57 Branch: refs/heads/camel-2.17.x Commit: 441e5b57770f70c6f7d86eadeadd7ae422c95c5f Parents: 0570a2a Author: syakimovich <s0yakimov...@gmail.com> Authored: Sun Apr 3 14:25:01 2016 +0300 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Apr 4 08:29:57 2016 +0200 ---------------------------------------------------------------------- .../component/schematron/SchematronEndpoint.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/441e5b57/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java index ccd6bea..0a78f9f 100644 --- a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java +++ b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java @@ -17,6 +17,7 @@ package org.apache.camel.component.schematron; import java.io.File; +import java.io.FileNotFoundException; import java.io.InputStream; import javax.xml.transform.Templates; import javax.xml.transform.TransformerFactory; @@ -129,11 +130,16 @@ public class SchematronEndpoint extends DefaultEndpoint { LOG.debug("Reading schematron rules from class path {}", path); InputStream schRules = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), path); rules = TemplatesFactory.newInstance().getTemplates(schRules, transformerFactory); - } catch (Exception e) { + } catch (Exception classPathException) { // Attempts from the file system. - LOG.debug("Schamatron rules not found in class path, attempting file system {}", path); - InputStream schRules = FileUtils.openInputStream(new File(path)); - rules = TemplatesFactory.newInstance().getTemplates(schRules, transformerFactory); + LOG.debug("Error loading schematron rules from class path, attempting file system {}", path); + try{ + InputStream schRules = FileUtils.openInputStream(new File(path)); + rules = TemplatesFactory.newInstance().getTemplates(schRules, transformerFactory); + } catch (FileNotFoundException e) { + LOG.debug("Schematron rules not found in the file system {}", path); + throw classPathException; // Can be more meaningful, for example, xslt compilation error. + } } // rules not found in class path nor in file system.