Refactor the error messages string build