Closed
Description
If the __repr__
of a local object fails, it gets reported as "<broken repr>
":
sentry-python/sentry_sdk/utils.py
Lines 416 to 451 in d7cf16c
It would be more helpful if it would include more information there, e.g. at least the class name of the exception.
It could also be something more sophisticated like:
def _try_repr_or_str(obj):
try:
return repr(obj)
except (KeyboardInterrupt, SystemExit):
raise
except BaseException:
return '{}("{}")'.format(type(obj).__name__, obj)
def _format_repr_exception(exc: BaseException, obj: Any) -> str:
try:
exc_info = _try_repr_or_str(exc)
except (KeyboardInterrupt, SystemExit):
raise
except BaseException as exc:
exc_info = "unpresentable exception ({})".format(_try_repr_or_str(exc))
return "<[{} raised in repr()] {} object at 0x{:x}>".format(
exc_info, type(obj).__name__, id(obj)
)
This would help with investigating why a repr
is broken actually, e.g. with celery/py-amqp#361.
(slightly related: there was some related (still open) PR for raven-python about this already: getsentry/raven-python#1294)
Metadata
Metadata
Assignees
Labels
No labels