mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
issues found with sentry
This commit is contained in:
parent
04412ec035
commit
5e1f67d162
3 changed files with 6 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from app import cache, db
|
from app import cache, db
|
||||||
from app.constants import *
|
from app.constants import *
|
||||||
from app.models import Community, CommunityMember, Post, PostReply, PostVote, User
|
from app.models import Community, CommunityMember, Post, PostReply, PostVote, User
|
||||||
|
|
|
@ -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)
|
response = httpx_client.get(uri, params=payload_str, headers=headers, timeout=timeout * 2, follow_redirects=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.info(f"{uri} {connection_error}")
|
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:
|
except httpx.HTTPError as read_timeout:
|
||||||
try: # retry, this time with a longer timeout
|
try: # retry, this time with a longer timeout
|
||||||
sleep(random.randint(3, 10))
|
sleep(random.randint(3, 10))
|
||||||
response = httpx_client.get(uri, params=payload_str, headers=headers, timeout=timeout * 2, follow_redirects=True)
|
response = httpx_client.get(uri, params=payload_str, headers=headers, timeout=timeout * 2, follow_redirects=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.info(f"{uri} {read_timeout}")
|
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
|
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)
|
response = httpx_client.head(uri, params=params, headers=headers, timeout=5, allow_redirects=True)
|
||||||
except httpx.HTTPError as er:
|
except httpx.HTTPError as er:
|
||||||
current_app.logger.info(f"{uri} {er}")
|
current_app.logger.info(f"{uri} {er}")
|
||||||
raise httpx.HTTPError from er
|
raise httpx.HTTPError(f"HTTPError: {str(er)}") from er
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ def app_context_processor():
|
||||||
def getmtime(filename):
|
def getmtime(filename):
|
||||||
return os.path.getmtime('app/static/' + filename)
|
return os.path.getmtime('app/static/' + filename)
|
||||||
return dict(getmtime=getmtime, instance_domain=current_app.config['SERVER_NAME'], debug_mode=current_app.debug,
|
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_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,
|
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,
|
SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
|
||||||
|
|
Loading…
Reference in a new issue