move error message formatting to the view