pipe error messages through single function