mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Better sentry error reporting
This commit is contained in:
parent
8e1f281cbf
commit
2bcb842114
2 changed files with 21 additions and 1 deletions
|
@ -14,4 +14,5 @@ markovify
|
|||
praw
|
||||
dice
|
||||
raven[flask]
|
||||
coloredlogs
|
||||
coloredlogs
|
||||
sentry_sdk
|
|
@ -8,7 +8,9 @@ import typing
|
|||
import telegram
|
||||
import sys
|
||||
import coloredlogs
|
||||
import requests
|
||||
from dirty import Dirty
|
||||
from sentry_sdk import configure_scope
|
||||
|
||||
logging.getLogger().disabled = True
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -34,6 +36,23 @@ def update_block(session: db.Session, block: list, delay: float=0, change_callba
|
|||
t = time.clock()
|
||||
try:
|
||||
change = item.update(session=session)
|
||||
except requests.exceptions.HTTPError as e:
|
||||
with configure_scope() as scope:
|
||||
if str(e.response.status_code).startswith("5"):
|
||||
scope.level = "warning"
|
||||
logger.warning(f"Server error {sys.exc_info()} while updating {repr(item)}.")
|
||||
else:
|
||||
scope.level = "error"
|
||||
logger.error(f"Error {sys.exc_info()} while updating {repr(item)}.")
|
||||
sentry.extra_context({
|
||||
"item": repr(item),
|
||||
"response": {
|
||||
"code": e.response.status_code,
|
||||
"text": e.response.text
|
||||
}
|
||||
})
|
||||
sentry.captureException()
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.warning(f"Error {sys.exc_info()} while updating {repr(item)}.")
|
||||
sentry.extra_context({
|
||||
|
|
Loading…
Reference in a new issue