Skip to content

Commit 12d3e85

Browse files
committed
Chain fetcher errors in composer lookup
Keep track of the last exception raised by candidate fetchers and attach it as the cause when no fetcher succeeds. This preserves the underlying failure context (for example remote HTTP/auth errors) while still raising the existing ValueError with supported fetchers.
1 parent 928584b commit 12d3e85

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pyenzyme/composer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,21 @@ def _fetch_with_fetchers(
197197
Raises:
198198
ValueError: If no fetcher can handle the given entity ID
199199
"""
200+
last_error: Optional[Exception] = None
200201
for fetcher in fetchers:
201202
try:
202203
return fetcher(entity_id)
203-
except Exception:
204+
except Exception as e:
205+
last_error = e
204206
continue
205207

206208
fetcher_names = ", ".join(f.__name__ for f in fetchers)
209+
# Chain the last underlying error so callers can inspect the real cause
210+
# (e.g. an HTTP 403 from a remote database blocked in CI).
207211
raise ValueError(
208212
f"No {entity_type} fetcher found for {entity_id}. "
209213
f"Supported fetchers: {fetcher_names}"
210-
)
214+
) from last_error
211215

212216

213217
def _remove_duplicates(objects: List[Any]) -> List[Any]:

0 commit comments

Comments
 (0)