Skip to content

Commit

Permalink
chore(handle): show line info if traceback
Browse files Browse the repository at this point in the history
  • Loading branch information
benjavicente committed Jul 30, 2023
1 parent 4e36cbe commit 0944d17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/bc_scraper/actions/errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from datetime import datetime
import json
from django.conf import settings
import logging

log = logging.getLogger("scraper")


def handle(context, err):
log.error("%s", err)
if isinstance(err, Exception) and err.__traceback__:
filename = err.__traceback__.tb_frame.f_code.co_filename
line_number = err.__traceback__.tb_lineno
log.error("Error at %s:%s", filename, line_number)
log.error("Context: %s", json.dumps(context, indent=2))

0 comments on commit 0944d17

Please sign in to comment.