Catch file reader error and use dummy file instead

By reading another post from 2016, it seems the file reader (and excel reader too) fail if the configuration is incorrect but is not caught by the try/catch. They resolved it by checking if the file exists, but what if the file exists but has a different format? What is the correct way of catching that configuration error?