summaryrefslogtreecommitdiff
path: root/sphinx/events.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-02 23:26:14 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-04 22:35:48 +0900
commit654458b525d2a6c43f0bb5488297fdc20f34f93d (patch)
tree8a27ecdfa38b236aa8e8791e0685d9643be4bb23 /sphinx/events.py
parent284d9e703bf9919c34414353afd5992218518745 (diff)
downloadsphinx-git-654458b525d2a6c43f0bb5488297fdc20f34f93d.tar.gz
Close #8813: Show what extension caused it on errors on event handler
Show the module name of the event handler on the error inside it to let users know a hint of the error.
Diffstat (limited to 'sphinx/events.py')
-rw-r--r--sphinx/events.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/sphinx/events.py b/sphinx/events.py
index 806a6e55d..e3a3b964f 100644
--- a/sphinx/events.py
+++ b/sphinx/events.py
@@ -19,6 +19,7 @@ from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.errors import ExtensionError, SphinxError
from sphinx.locale import __
from sphinx.util import logging
+from sphinx.util.inspect import safe_getattr
if False:
# For type annotation
@@ -114,8 +115,9 @@ class EventManager:
except SphinxError:
raise
except Exception as exc:
+ modname = safe_getattr(listener.handler, '__module__', None)
raise ExtensionError(__("Handler %r for event %r threw an exception") %
- (listener.handler, name), exc) from exc
+ (listener.handler, name), exc, modname=modname) from exc
return results
def emit_firstresult(self, name: str, *args: Any,