def raise_on_failure(mainfunc):
try:<EOL><INDENT>errors = mainfunc()<EOL>if errors:<EOL><INDENT>exit(errors)<EOL><DEDENT><DEDENT>except CalledProcessError as error:<EOL><INDENT>exit(error.returncode)<EOL><DEDENT>except SystemExit as error:<EOL><INDENT>if error.code:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>except KeyboardInterrupt:  <EOL><INDENT>exit(<NUM_LIT:1>)<EOL><DEDENT>
raise if and only if mainfunc fails