Eliminate a bunch of duplication by extracting printError()