Skip to content

Commit

Permalink
Update providers exception info format
Browse files Browse the repository at this point in the history
  • Loading branch information
vitiko98 committed Sep 14, 2023
1 parent b736f26 commit ceb947d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bazarr/app/get_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from utilities.analytics import event_tracker


_TRACEBACK_RE = re.compile(r'File "(.*?)", line (\d+)')
_TRACEBACK_RE = re.compile(r'File "(.*?providers/.*?)", line (\d+)')


def time_until_midnight(timezone):
Expand Down Expand Up @@ -357,20 +357,21 @@ def provider_throttle(name, exception):


def _get_traceback_info(exc: Exception):
traceback_str = " ".join(traceback.format_tb(exc.__traceback__))
traceback_str = " ".join(traceback.format_exception(type(exc), exc, exc.__traceback__))

clean_msg = str(exc).replace("\n", " ").strip()

line_info = _TRACEBACK_RE.search(traceback_str)
line_info = _TRACEBACK_RE.findall(traceback_str)

# Value info char len is 100
# Value info max chars len is 100

if line_info is None:
if not line_info:
return clean_msg[:100]

file_, line = line_info.groups()
line_info = line_info[-1]
file_, line = line_info

extra = f"' ~ {file_}@{line}"[:90]
extra = f"' ~ {os.path.basename(file_)}@{line}"[:90]
message = f"'{clean_msg}"[:100 - len(extra)]

return message + extra
Expand Down

0 comments on commit ceb947d

Please sign in to comment.