issues found with sentry

This commit is contained in:
rimu 2024-09-21 13:23:14 +12:00
parent 04412ec035
commit 5e1f67d162
3 changed files with 6 additions and 4 deletions

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from app import cache, db
from app.constants import *
from app.models import Community, CommunityMember, Post, PostReply, PostVote, User

View file

@ -102,14 +102,14 @@ def get_request(uri, params=None, headers=None) -> httpx.Response:
response = httpx_client.get(uri, params=payload_str, headers=headers, timeout=timeout * 2, follow_redirects=True)
except Exception as e:
current_app.logger.info(f"{uri} {connection_error}")
raise httpx_client.ReadError from connection_error
raise httpx_client.ReadError(f"HTTPReadError: {str(e)}") from connection_error
except httpx.HTTPError as read_timeout:
try: # retry, this time with a longer timeout
sleep(random.randint(3, 10))
response = httpx_client.get(uri, params=payload_str, headers=headers, timeout=timeout * 2, follow_redirects=True)
except Exception as e:
current_app.logger.info(f"{uri} {read_timeout}")
raise httpx.HTTPError from read_timeout
raise httpx.HTTPError(f"HTTPError: {str(e)}") from read_timeout
return response
@ -124,7 +124,7 @@ def head_request(uri, params=None, headers=None) -> httpx.Response:
response = httpx_client.head(uri, params=params, headers=headers, timeout=5, allow_redirects=True)
except httpx.HTTPError as er:
current_app.logger.info(f"{uri} {er}")
raise httpx.HTTPError from er
raise httpx.HTTPError(f"HTTPError: {str(er)}") from er
return response

View file

@ -24,7 +24,7 @@ def app_context_processor():
def getmtime(filename):
return os.path.getmtime('app/static/' + filename)
return dict(getmtime=getmtime, instance_domain=current_app.config['SERVER_NAME'], debug_mode=current_app.debug,
arrow=arrow, locale=g.locale,
arrow=arrow, locale=g.locale if hasattr(g, 'locale') else None,
POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE,
POST_TYPE_ARTICLE=POST_TYPE_ARTICLE, POST_TYPE_VIDEO=POST_TYPE_VIDEO, POST_TYPE_POLL=POST_TYPE_POLL,
SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,