nixos-rebuild-ng: exit with the error code of the process when CalledProcessError

This commit is contained in:
Thiago Kenji Okada
2024-12-16 22:05:46 +00:00
parent 8c835bfe21
commit b91be5b0e0
@@ -485,6 +485,15 @@ def main() -> None:
try:
execute(sys.argv)
except CalledProcessError as ex:
if logger.level == logging.DEBUG:
import traceback
traceback.print_exc()
else:
print(str(ex), file=sys.stderr)
# Exit with the error code of the process that failed
sys.exit(ex.returncode)
except (Exception, KeyboardInterrupt) as ex:
if logger.level == logging.DEBUG:
raise