Handle both path string and filehandle input on exceptions

Cast the file input (which can be a filepath string or a file handle) to strings so that the nice named exceptions don't break when being raised