I use subprocess to run a script. But that called script itself uses subprocess to execute some commands. The problem is that when I catch the exception in the outer script, it just says that there was an error in the called script.
So, my question is how can I propagate the error from the inner script to the outer script, so that I know the exact reason of what happened in the inner script.
This is how I catch exceptions and exit on error, with subprocess.
try:
output = subprocess.check_output(cmd)
except Exception as e:
print(str(e))
sys.exit(1)