Refactor the error rendering lines into one to avoid repetition