Skip to content
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

Handling Skybot exceptions when searching for asteroids #379

Open
AIofHuman opened this issue Jan 20, 2024 · 0 comments
Open

Handling Skybot exceptions when searching for asteroids #379

AIofHuman opened this issue Jan 20, 2024 · 0 comments

Comments

@AIofHuman
Copy link

AIofHuman commented Jan 20, 2024

If the Skybot does not find a solar system object in the specified search area (Skybot.cone_search), it throws an exception such as RuntimeError. For other exceptions (incorrect data or lack of Internet), the type of exceptions is the same, only the text of the messages differs. It is necessary to differ between object "not found" events and "service error" events. Possible solution:

try:
    results = Skybot.cone_search(field, 0.0041667*u.deg, earthed_time, location='I41')
    return len(results) > 0, results[0]['Name']
except Exception as e:
    if len(e.args)>0 and e.args[0][0:22]=='No solar system object':
        return False, 'No object'
    else:
        print(f'Exception {e.args[0]}')     
        return False, 'Service error'
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

No branches or pull requests

1 participant