Don't crash when launch service provider is unknown
This commit is contained in:
parent
697f317c5e
commit
6199c2affd
|
@ -86,8 +86,14 @@ launch_providers = {
|
||||||
|
|
||||||
def summarize_launch(launch: Launch) -> Summary:
|
def summarize_launch(launch: Launch) -> Summary:
|
||||||
"""Summarize rocket launch."""
|
"""Summarize rocket launch."""
|
||||||
|
try:
|
||||||
launch_provider = launch["launch_service_provider"]["name"]
|
launch_provider = launch["launch_service_provider"]["name"]
|
||||||
launch_provider_abbrev = launch_providers.get(launch_provider)
|
launch_provider_abbrev = launch_providers.get(launch_provider)
|
||||||
|
launch_provider_type = launch["launch_service_provider"]["type"]
|
||||||
|
except (TypeError, IndexError):
|
||||||
|
launch_provider = None
|
||||||
|
launch_provider_abbrev = None
|
||||||
|
launch_provider_type = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
net_precision = launch["net_precision"]["name"]
|
net_precision = launch["net_precision"]["name"]
|
||||||
|
@ -109,7 +115,7 @@ def summarize_launch(launch: Launch) -> Summary:
|
||||||
"window_end": launch["window_end"],
|
"window_end": launch["window_end"],
|
||||||
"launch_provider": launch_provider,
|
"launch_provider": launch_provider,
|
||||||
"launch_provider_abbrev": launch_provider_abbrev,
|
"launch_provider_abbrev": launch_provider_abbrev,
|
||||||
"launch_provider_type": launch["launch_service_provider"]["type"],
|
"launch_provider_type": launch_provider_type,
|
||||||
"rocket": launch["rocket"]["configuration"]["full_name"],
|
"rocket": launch["rocket"]["configuration"]["full_name"],
|
||||||
"mission": launch["mission"],
|
"mission": launch["mission"],
|
||||||
"mission_name": (launch["mission"]["name"] if launch["mission"] else None),
|
"mission_name": (launch["mission"]["name"] if launch["mission"] else None),
|
||||||
|
|
Loading…
Reference in a new issue