Skip to content

Commit

Permalink
Merge pull request #1927 from camptocamp/better-error
Browse files Browse the repository at this point in the history
Better error message
  • Loading branch information
sbrunner authored Sep 3, 2024
2 parents d638d28 + f4501f7 commit 1fd71a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tilecloud/store/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ def get_one(self, tile: Tile) -> Optional[Tile]:
if response.status_code < 300:
if response.status_code != 200:
tile.error = (
f"Unsupported status code {response.status_code}: {response.reason}\nURL: {url}"
f"URL: {url}\nUnsupported status code {response.status_code}: {response.reason}"
)
if tile.content_type:
if tile.content_type.startswith("image/"):
tile.data = response.content
else:
tile.error = f"{response.text}\nURL: {url}"
tile.error = f"URL: {url}\n{response.text}"
else:
if self.allows_no_contenttype:
tile.data = response.content
else:
tile.error = f"The Content-Type header is missing\nURL: {url}"
tile.error = f"URL: {url}\nThe Content-Type header is missing"

else:
tile.error = f"{response.reason}\nURL: {url}"
tile.error = f"URL: {url}\n{response.status_code}: {response.reason}\n{response.text}"
except requests.exceptions.RequestException as exception:
tile.error = exception
return tile
Expand Down

0 comments on commit 1fd71a2

Please sign in to comment.