added function exitIfNonZeroExitCode(errorMessage), that outputs an error message and exits if exit code is non-zero