Skip to content

Commit

Permalink
🚑 Fix un-raised NameResolveError and improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Aug 6, 2024
1 parent 991045a commit 3d74b31
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ipyaladin/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,17 @@ def target(self, target: Union[str, SkyCoord, Tuple[float, float]]) -> None:
try:
target = parse_coordinate_string(target, self._survey_body)
except NameResolveError as e:
# If the widget is not ready, we don't know if the base survey is
# celestial or planetary so the error can be caused by two factors
if not self._ready:
raise WidgetCommunicationError(
f"Either '{target}' is not a valid object name, or "
f"the survey body type is not yet defined so you "
f"need to set the target from another cell."
f"Either '{target}' is not a valid celestial object name, "
f"or the survey body type is not yet defined so you "
f"need to wait for the widget to be fully loaded."
) from e
# If the widget is ready, the error is caused by the target name
# that is not a valid celestial object name
raise e
elif not isinstance(target, SkyCoord) and not isinstance(
target, Tuple
): # If the target is not str or SkyCoord
Expand Down

0 comments on commit 3d74b31

Please sign in to comment.