Skip to content

Commit f1e98b3

Browse files
committed
Refactor error handling in get_uniprot_summary_helper to improve structure validation and logging
1 parent 4b7c85e commit f1e98b3

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

app/uniprot/helper.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,18 @@ async def get_uniprot_summary_helper(
123123

124124
for item in final_result:
125125
# Remove erroneous responses
126-
try:
127-
Overview(**item["structures"][0])
128-
final_structures.extend(item["structures"])
129-
except pydantic.ValidationError:
130-
provider = item["structures"][0].get("provider")
131-
if provider:
132-
logger.warning(
133-
f"{provider} returned an erroneous response for {qualifier}"
134-
)
135-
except Exception:
136-
pass
126+
for structure in item["structures"]:
127+
try:
128+
Overview(**structure)
129+
final_structures.append(structure)
130+
except pydantic.ValidationError:
131+
provider = structure.get("provider")
132+
if provider:
133+
logger.warning(
134+
f"{provider} returned an erroneous response for {qualifier}"
135+
)
136+
except Exception:
137+
pass
137138

138139
if not final_structures:
139140
return None

0 commit comments

Comments
 (0)