Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sentry errors #191

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ffun/ffun/feeds/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class FeedError(enum.IntEnum):
network_ssl_connection_error = 1014
network_all_connection_attempts_failed = 1015
network_received_unkomplete_body = 1016
network_decoding_error = 1017
network_read_error = 1018
network_temporary_failure_in_name_resolution = 1019

parsing_unknown = 2000
parsing_base_error = 2001
Expand All @@ -44,6 +47,8 @@ class FeedError(enum.IntEnum):

proxy_could_not_resolve_host = 4001
proxy_connection_refused = 4002
proxy_connection_403 = 4003
proxy_no_route_to_host = 4004


class Feed(BaseEntity):
Expand Down
29 changes: 27 additions & 2 deletions ffun/ffun/loader/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,26 @@ async def load_content( # noqa: CFQ001, CCR001, C901 # pylint: disable=R0912, R

raise errors.LoadError(feed_error_code=error_code) from e

except httpx.ReadError as e:
message = str(e)

if message == "":
error_code = FeedError.network_read_error
log.warning("network_read_error")
else:
log.exception("unknown_read_error_while_loading_feed")

raise errors.LoadError(feed_error_code=error_code) from e

except httpx.ConnectError as e:
message = str(e)

if "[Errno -2]" in message:
log.warning("network_name_or_service_not_known")
error_code = FeedError.network_name_or_service_not_known
elif "[Errno -3]" in message:
log.warning("network_temporary_failure_in_name_resolution")
error_code = FeedError.network_temporary_failure_in_name_resolution
elif "[Errno -5]" in message:
log.warning("no_address_associated_with_hostname")
error_code = FeedError.network_no_address_associated_with_hostname
Expand Down Expand Up @@ -128,16 +142,27 @@ async def load_content( # noqa: CFQ001, CCR001, C901 # pylint: disable=R0912, R
message = str(e)

if message.startswith("502 Could not resolve host"):
log.warning("network_could_not_resolve_host")
log.warning("proxy_could_not_resolve_host")
error_code = FeedError.proxy_could_not_resolve_host
elif "TUN_ERR" in message and "ECONNREFUSED" in message:
log.warning("network_connection_refused")
log.warning("proxy_connection_refused")
error_code = FeedError.proxy_connection_refused
elif "TUN_ERR" in message and "EHOSTUNREACH" in message:
log.warning("proxy_no_route_to_host")
error_code = FeedError.proxy_no_route_to_host
elif "403" in message:
log.warning("proxy_connection_403")
error_code = FeedError.proxy_connection_403
else:
log.exception("unknown_proxy_error_while_loading_feed")

raise errors.LoadError(feed_error_code=error_code) from e

except httpx.DecodingError as e:
log.warning("network_decoding_error")
error_code = FeedError.network_decoding_error
raise errors.LoadError(feed_error_code=error_code) from e

except Exception as e:
log.exception("error_while_loading_feed")
raise errors.LoadError(feed_error_code=error_code) from e
Expand Down
Loading