|
try: |
|
module = importlib.import_module(module_path) |
|
except Exception as e: |
|
msg = f'Error importing {module!r}: {e.__class__.__name__}: {e}' |
|
if not skip_errors: |
|
raise ImportError(msg) |
Change raise ImportError(msg) to raise ImportError(msg) from e:
try:
module = importlib.import_module(module_path)
except Exception as e:
msg = f'Error importing {module!r}: {e.__class__.__name__}: {e}'
if not skip_errors:
raise ImportError(msg) from e
This improves exceptions readability.
I didn't search for other places in the repository, there're probably more places where raise x from y would be useful.
pdoc/pdoc/__init__.py
Lines 227 to 232 in f8704ec
Change
raise ImportError(msg)toraise ImportError(msg) from e:This improves exceptions readability.
I didn't search for other places in the repository, there're probably more places where
raise x from ywould be useful.