Skip to content

Commit

Permalink
LinkManager: fix inaccuracy in exception message for non-existent l…
Browse files Browse the repository at this point in the history
…ink (#4388)

The link manager was always referring to an 'input link' while it should
instead refer on an 'input link label' or 'output link label' depending
on the value of the link direction, determined by the `self._incoming`
attribute.
  • Loading branch information
giovannipizzi authored Sep 24, 2020
1 parent 559abba commit 0184518
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aiida/orm/utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def __getattr__(self, name):
# `AttributeError`, so that `getattr(node.inputs, 'some_label', some_default)` returns `some_default`.
# Otherwise, the exception is not caught by `getattr` and is propagated, instead of returning the default.
raise NotExistentAttributeError(
"Node '{}' does not have an input with link '{}'".format(self._node.pk, name)
"Node '{}' does not have an {}put with link label '{}'".format(
self._node.pk, 'in' if self._incoming else 'out', name
)
)

def __getitem__(self, name):
Expand All @@ -101,7 +103,11 @@ def __getitem__(self, name):
# Note: in order for this class to behave as a dictionary, we raise an exception that also inherits from
# `KeyError` - in this way, users can use the standard construct `try/except KeyError` and this will behave
# like a standard dictionary.
raise NotExistentKeyError("Node '{}' does not have an input with link '{}'".format(self._node.pk, name))
raise NotExistentKeyError(
"Node '{}' does not have an {}put with link label '{}'".format(
self._node.pk, 'in' if self._incoming else 'out', name
)
)

def __str__(self):
"""Return a string representation of the manager"""
Expand Down

0 comments on commit 0184518

Please sign in to comment.