3
0
Fork 0
forked from mirrors/nixpkgs

nixos-render-docs: print exception trees by __cause__

__context__ is always set to the prior exception, even when not using
the raise from form. __cause__ is only set during raise from. use
__cause__ so we can override a leaf exception (eg KeyError to something
more meaningful).
This commit is contained in:
pennae 2023-02-11 19:42:53 +01:00
parent 99306697f8
commit d004105003

View file

@ -29,9 +29,9 @@ def pretty_print_exc(e: BaseException, *, _desc_text: str = "error") -> None:
print(textwrap.indent(extra_info, "\t"), file=sys.stderr, end="")
else:
print(e)
if e.__context__ is not None:
if e.__cause__ is not None:
print("", file=sys.stderr)
pretty_print_exc(e.__context__, _desc_text="caused by")
pretty_print_exc(e.__cause__, _desc_text="caused by")
def main() -> None:
parser = argparse.ArgumentParser(description='render nixos manual bits')