You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Sergey Yakimovich (JIRA)" <ji...@apache.org> on 2016/04/03 14:05:25 UTC
[jira] [Commented] (CAMEL-9549) camel-schematron - More fine
grained error messages when compiling the schema
[ https://issues.apache.org/jira/browse/CAMEL-9549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15223235#comment-15223235 ]
Sergey Yakimovich commented on CAMEL-9549:
------------------------------------------
I looked into it and the wrong error is shown because of the following. Rules first searched in the classpath. If there is an exception, for example, parsing error, file system is searched and FileNotFoundException is thrown. I propose the following change. Change this:
{code:title=SchematronEndpoint.java|borderStyle=solid}
try {
// Attempt to read the schematron rules from the class path first.
LOG.debug("Reading schematron rules from class path {}", path);
InputStream schRules = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), path);
rules = TemplatesFactory.newInstance().getTemplates(schRules, transformerFactory);
} catch (Exception e) {
// 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);
}
{code}
to this:
{code:title=SchematronEndpoint.java|borderStyle=solid}
try {
// Attempt to read the schematron rules from the class path first.
LOG.debug("Reading schematron rules from class path {}", path);
InputStream schRules = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), path);
rules = TemplatesFactory.newInstance().getTemplates(schRules, transformerFactory);
} catch (Exception classPathException) {
// Attempts from the file system.
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.
}
}
{code}
I will create a pull request if this is ok.
> camel-schematron - More fine grained error messages when compiling the schema
> -----------------------------------------------------------------------------
>
> Key: CAMEL-9549
> URL: https://issues.apache.org/jira/browse/CAMEL-9549
> Project: Camel
> Issue Type: Improvement
> Components: camel-schematron
> Affects Versions: 2.15.3
> Reporter: Johan Mörén
> Priority: Minor
>
> When pre-compiling the schematron rules files. Errors such as xslt-compilation errors, includes not found etc. are always caught and presented with an error message saying incorrectly that the schematron rules file could not be found.
> In the two errors above the file has been found but compilation of it has failed.
> To make troubleshooting easier i think that a more fine grained error handling could provide the user with a better view of what the underlying error really is.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)