Tidy up response code handling for error output