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 9cd9a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ipyaladin/utils/_coordinate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def _from_name_on_planet(string: str, body: str) -> SkyCoord:
)
if "+West" in system:
lon = 360 - lon
# Currently we use ICRS for all planetary bodies, but this could be changed
# in a future Aladin Lite version.
return SkyCoord(ra=lon, dec=lat, frame="icrs", unit="deg")


Expand Down
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 9cd9a8c

Please sign in to comment.