Comment by necovek

Comment by necovek 7 days ago

1 reply

There is a log message that won't be output in that case: whether getting a full, "native" FileNotFound exception is better is beside the point, since the goal of the code was obviously to print a custom error message.

And it's trivial to achieve the desired effect sanely:

  try:
      with open(...) ...

  except FileNotFound:
      logger.error(...)
      raise
It'd even be fewer lines of code.
theteapot 6 days ago

Or even fewer by doing it in a global exception handler instead of every time you try to open a file, since all your doing is piping the error though logger.