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:
parent
99306697f8
commit
d004105003
|
@ -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="")
|
print(textwrap.indent(extra_info, "\t"), file=sys.stderr, end="")
|
||||||
else:
|
else:
|
||||||
print(e)
|
print(e)
|
||||||
if e.__context__ is not None:
|
if e.__cause__ is not None:
|
||||||
print("", file=sys.stderr)
|
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:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(description='render nixos manual bits')
|
parser = argparse.ArgumentParser(description='render nixos manual bits')
|
||||||
|
|
Loading…
Reference in a new issue