Skip to content

Better error catching in find_source #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

kelle
Copy link
Contributor

@kelle kelle commented Jun 30, 2025

Improved error catching in find_source when sources are given and the ra/dec column names are needed to search for coordinate matches.

@kelle kelle requested a review from Copilot June 30, 2025 21:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The purpose of this PR is to improve error handling in the find_source_in_db function when invalid column names (for ra/dec) are provided. Key changes include:

  • Adding a test case to verify that a proper AstroDBError is raised and contains an informative error message when bad column names are used.
  • Introducing a try/except block in the db.query_region call to catch KeyError and log a more descriptive error message before raising an AstroDBError.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_sources.py Added a test to assert the error message contains a suggestion to use correct column names.
astrodb_utils/sources.py Wrapped the db.query_region call in a try/except block to catch KeyError and raise a detailed error.
Comments suppressed due to low confidence (2)

tests/test_sources.py:163

  • [nitpick] Consider renaming the pytest.raises context variable (e.g., 'exc') to more clearly differentiate it from the error message content.
    with pytest.raises(AstroDBError) as error_message:

astrodb_utils/sources.py:130

  • If db.query_region might raise exceptions other than KeyError in cases of misconfigured column names, consider handling those cases or document that only KeyError is expected here.
            try:

@kelle kelle merged commit 3c3da8f into astrodbtoolkit:main Jul 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants