Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-1151

STKFunctions#getReferencedContent should not wrap and re-throw RepositoryException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.5
    • None
    • None
    • None

          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.

        Acceptance criteria

              jsimak Jaroslav Simak
              jsimak Jaroslav Simak
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: