Skip to content

Commit

Permalink
Improve download images logs (#466)
Browse files Browse the repository at this point in the history
Some of the exception caught by the download images component returned
an empty string since the exception object does not always have a
**string representation** .

Example:

```python
except Exception as e:
    logger.warning(f"Skipping {url}: {e)")
```

returns: 

```bash
Skipping https://2.gravatar.com/avatar/2d7699b189a0d1e40a506aa3b8cad2dc?s=48&d=identicon&r=G: 
```

This makes it difficult to trace back why a url was skipped. Changing to
`repr(e)` seems to fix it since most exeception objects seem to have a
**printable representational string** (at least the httpx ones)
  • Loading branch information
PhilippeMoussalli authored Sep 27, 2023
1 parent b136bdb commit 7dbed65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/download_images/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def download_image(self, url: str) -> t.Optional[bytes]:
headers={"User-Agent": user_agent_string})
image_stream = response.content
except Exception as e:
logger.warning(f"Skipping {url}: {e}")
logger.warning(f"Skipping {url}: {repr(e)}")
image_stream = None

return image_stream
Expand Down

0 comments on commit 7dbed65

Please sign in to comment.