refactoring: renamed printError method to printErrorAndExit