Do not use the file name in errors unless it exists

Fixes #1182
When do we not have refFile?   Can you comment the case where this might happen?

Also, can we have a test for this?