INNER CODE UNIT · Python
_fail
ythx-101/x-tweet-fetcher · src/xtf/cli.py:31
def _fail(result: dict[str, Any], exc: XtfError) -> dict[str, Any]:
result["error"] = str(exc) or exc.code
result["error_code"] = exc.code
if getattr(exc, "causes", None):
result["error_causes"] = {k: str(v) for k, v in exc.causes.items()}
return result
def _archive_if_requested(args, result: dict[str, Any], tweet_dicts) -> None:
"""Archive fetched tweet dicts when --ledger is set (never fatal).
Without --ledger this is a no-op, keeping legacy behavior identical.
"""
if not args.ledger:
return
if result.get("error") or not tweet_dicts:
return
db = Path(args.ledger).expanduser()