Don't suppress exception chaining for optional dependencies by takluyver · Pull Request #43882 · pandas-dev/pandas (original) (raw)

I've just been helping someone for whom the helpful error message appears to have obscured the real cause of the problem. Specifically, Jinja2 is present, but one of its dependencies is not. So the error message saying "Missing optional dependency: 'Jinja2'..." is rather confusing.

Automatic exception chaining is really great for things like this - you can provide a more descriptive error message while still having the original exception details available for inspection. I'd argue that it should only be disabled (raise ... from None) if you're absolutely sure that there will be no useful information in the original exception.