format error message with pathname