Skip to content

Commit

Permalink
Merge pull request #472 from lsst/tickets/DM-27971
Browse files Browse the repository at this point in the history
DM-27971: Add better error message if the dimension element is not known
  • Loading branch information
timj committed Feb 9, 2021
2 parents 509ddab + 15ecec8 commit df82ec3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/dimensions/_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __str__(self) -> str:
def __repr__(self) -> str:
return "{}.RecordClass({})".format(
self.definition.name,
", ".join(f"name={getattr(self, name)!r}" for name in self.__slots__)
", ".join(f"{name}={getattr(self, name)!r}" for name in self.__slots__)
)

def __reduce__(self) -> tuple:
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/daf/butler/registry/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,11 @@ def queryDimensionRecords(self, element: Union[DimensionElement, str], *,
Data IDs matching the given query parameters.
"""
if not isinstance(element, DimensionElement):
element = self.dimensions[element]
try:
element = self.dimensions[element]
except KeyError as e:
raise KeyError(f"No such dimension '{element}', available dimensions: "
+ str(self.dimensions.getStaticElements())) from e
dataIds = self.queryDataIds(element.graph, dataId=dataId, datasets=datasets, collections=collections,
where=where, components=components, bind=bind, check=check, **kwargs)
return iter(self._managers.dimensions[element].fetch(dataIds))
Expand Down

0 comments on commit df82ec3

Please sign in to comment.