[MGNLSTK-1151] STKFunctions#getReferencedContent should not wrap and re-throw RepositoryException Created: 17/Apr/13  Updated: 25/Jun/13  Resolved: 18/Apr/13

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5

Type: Bug Priority: Major
Reporter: Jaroslav Simak Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty

 Description   
    public Node getReferencedContent(Node content, String idPropertyName, String referencedWorkspace) {
        try {
            if (content.hasProperty(idPropertyName)) {
                String identifier = PropertyUtil.getString(content, idPropertyName);
                return wrap(NodeUtil.getNodeByIdentifier(referencedWorkspace, identifier));
            }
        } catch (RepositoryException e) {
            log.error("can't read value '" + idPropertyName + "' of the Node '" + content.toString() + "'.", e);
            throw new RuntimeRepositoryException(e);
        }
        return null;
    }

I don't see any reason why this code shoud wrap RepositoryException and then throw it. There rather should be throws clause with RepositoryException so we can catche i.e. ItemNotFoundException if we need to.


Generated at Mon Feb 12 07:33:50 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.