def METHOD_NAME(cls, exc_info=None):
    if exc_info is None:
        exc_info = sys.exc_info()
    _, exc_value, _ = exc_info
    if exc_value is None:
        return None
    cached = getattr(exc_value, _CAPTURED_ERROR_MARKER, None)
    if cached is not None:
        return cached
    returned = cls(exc_info=exc_info)
    safe_set_attribute(exc_value, _CAPTURED_ERROR_MARKER, returned)
    return returned