pallets / jinja

A very fast and expressive template engine.
https://jinja.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
10.12k stars 1.6k forks source link

Fix error message for non-existing directory #1996

Open elektito opened 1 month ago

elektito commented 1 month ago

As described in issue #1995, the error message thrown when the template directory does not exist was very misleading. This is a simple attempt to fix that.

fixes #1995

davidism commented 1 month ago

This seems even less clear. It doesn't say what package, or what directory name. I'm pretty sure this specific message can happen in other cases too, not just when the directory doesn't exist, so you'll need to split out detection of that and raise a specific error.

elektito commented 1 month ago

If I understand correctly, in cases where the package/module does not exist, we get an assertion error. So this is left exclusively for cases where the template directory does not exist.

elektito commented 1 month ago

I could add the package name and template directory to the error message if you think that's better. My reasoning for not including them was that in most cases these are included as strings, so you could see it right in the stack trace.

elektito commented 1 month ago

I think if there is a case that we can find a package, but cannot find any path associated for it, this can happen too. Not quite sure if that's possible or not. But even in that case, the original error message doesn't make a lot of sense.