safer way to build error message, refs #6968