Bad error handling for method for
info.magnolia.templating.functions.TemplatingFunctions#link
---------------------------------------------------------------------------------------------
Key: MAGNOLIA-4671
URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-4671
Project: Magnolia
Issue Type: Improvement
Security Level: Public
Components: templating
Affects Versions: 4.5.4
Reporter: Per Andersson
Hi,
When calling the method
"info.magnolia.templating.functions.TemplatingFunctions#link" from freemarker
using:
{noformat}
<#assign dmsLink = cmsfn.link("dms", "/demo-docs/children/wizoz10") />
{noformat}
The only error visible for me is:
{noformat}
Error on line 95, column 11 in path/to/template
cmsfn.link("dms", "/demo-docs/children/wizoz10") is undefined.
It cannot be assigned to dmsLink
The problematic instruction:
----------
==> assignment: dmsLink=cmsfn.link("dms", "/demo-docs/children/wizoz10") [on
line 95, column 11 in path/to/template]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Error on line 95, column 11 in
path/to/template
cmsfn.link("dms", "/demo-docs/children/wizoz10") is undefined.
It cannot be assigned to dmsLink
at freemarker.core.Assignment.accept(Assignment.java:111)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
{noformat}
When downloading the source code I've found:
{noformat}
public String link(String workspace, String nodeIdentifier) {
try {
return LinkUtil.createLink(workspace, nodeIdentifier);
} catch (RepositoryException e) {
return null;
}
}
{noformat}
The real error "javax.jcr.RepositoryException: invalid identifier:
/demo-docs/children/wizoz10" was hidden from me because of this. I first
assumed that the method "link" was missing due to the error visible to me in
the log.
Better consistency for the error handling in this file would be appreciated.
Example:
{noformat}
public String link(String workspace, String nodeIdentifier) {
try {
return LinkUtil.createLink(workspace, nodeIdentifier);
} catch (RepositoryException e) {
log.error(e.getMessage(), e); // Print the real error in the log
return null;
}
}
{noformat}
Also I see other methods have the same problem, those should be updated as well.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------