diff --git a/swh/web/utils/highlightjs.py b/swh/web/utils/highlightjs.py --- a/swh/web/utils/highlightjs.py +++ b/swh/web/utils/highlightjs.py @@ -8,11 +8,10 @@ from typing import Dict from pygments.lexers import get_all_lexers, get_lexer_for_filename +from pygments.util import ClassNotFound from django.contrib.staticfiles.finders import find -from swh.web.utils.exc import sentry_capture_exception - @functools.lru_cache() def _hljs_languages_data(): @@ -140,8 +139,8 @@ # try to find a Pygment lexer try: lexer = get_lexer_for_filename(filename) - except Exception as exc: - sentry_capture_exception(exc) + except ClassNotFound: + pass # if there is a correspondence between the lexer and an hljs # language, return it if lexer and lexer.name in _pygments_lexer_to_hljs_language: