def METHOD_NAME(exc, max_depth=10):
    if isinstance(exc, Neo4jError) and exc.message is not None:
        return str(exc.message)
    depth = 0
    res = str(exc)
    while getattr(exc, "__cause__", None) is not None:
        depth += 1
        if depth >= max_depth:
            break
        res += f"\nCaused by: {exc.__cause__!r}"
        exc = exc.__cause__
    return res