FileNotFoundError thrown due to file name in file, rather than file itself

Loris Bennett loris.bennett at fu-berlin.de
Tue Nov 12 04:00:36 EST 2024


Chris Angelico <rosuav at gmail.com> writes:

> On Tue, 12 Nov 2024 at 01:59, Loris Bennett via Python-list
> <python-list at python.org> wrote:
>> 2. In terms of generating a helpful error message, how should one
>>    distinguish between the config file not existing and the log file not
>>    existing?
>
> By looking at the exception's attributes rather than assuming and
> hard-coding the path in your message? Or, even better, just let the
> exception bubble.

As Dieter also pointed out, I obviously made a mistake in assuming that
I knew what 'FileNotFound' was referring to.

However, it strikes me as not immediately obvious that the logging file
must exist at this point.  I can imagine a situation in which I want to
configure a default log file and create it if it missing.

Cheers,

Loris

-- 
This signature is currently under constuction.


More information about the Python-list mailing list