|
37 | 37 |
|
38 | 38 | try: |
39 | 39 | __version__ = importlib.metadata.version("pelican") |
40 | | -except Exception: |
| 40 | +except importlib.metadata.PackageNotFoundError: |
41 | 41 | __version__ = "unknown" |
42 | 42 |
|
43 | 43 | DEFAULT_CONFIG_NAME = "pelicanconf.py" |
@@ -78,11 +78,10 @@ def init_plugins(self): |
78 | 78 | try: |
79 | 79 | plugin.register() |
80 | 80 | self.plugins.append(plugin) |
81 | | - except Exception as e: |
82 | | - logger.error( |
83 | | - "Cannot register plugin `%s`\n%s", |
| 81 | + except Exception: |
| 82 | + logger.exception( |
| 83 | + "Cannot register plugin `%s`", |
84 | 84 | name, |
85 | | - e, |
86 | 85 | stacklevel=2, |
87 | 86 | ) |
88 | 87 | if self.settings.get("DEBUG", False): |
@@ -257,8 +256,8 @@ def __call__(self, parser, namespace, values, option_string): |
257 | 256 |
|
258 | 257 | try: |
259 | 258 | instance, settings = get_instance(namespace) |
260 | | - except Exception as e: |
261 | | - logger.critical("%s: %s", e.__class__.__name__, e) |
| 259 | + except Exception as e: # noqa: BLE001 (blind-except) |
| 260 | + logger.critical("%s", e.__class__.__name__, exc_info=True) |
262 | 261 | console.print_exception() |
263 | 262 | sys.exit(getattr(e, "exitcode", 1)) |
264 | 263 |
|
@@ -621,7 +620,8 @@ def listen(server, port, output, excqueue=None): |
621 | 620 | except Exception as e: |
622 | 621 | if excqueue is not None: |
623 | 622 | excqueue.put(traceback.format_exception_only(type(e), e)[-1]) |
624 | | - return |
| 623 | + else: |
| 624 | + logging.exception("Listening aborted unexpectedly.") |
625 | 625 |
|
626 | 626 | except KeyboardInterrupt: |
627 | 627 | httpd.socket.close() |
@@ -679,8 +679,8 @@ def main(argv=None): |
679 | 679 | pelican.run() |
680 | 680 | except KeyboardInterrupt: |
681 | 681 | logger.warning("Keyboard interrupt received. Exiting.") |
682 | | - except Exception as e: |
683 | | - logger.critical("%s: %s", e.__class__.__name__, e) |
| 682 | + except Exception as e: # noqa: BLE001 (blind-except) |
| 683 | + logger.critical("%s: %s", e.__class__.__name__, e, exc_info=True) |
684 | 684 |
|
685 | 685 | if args.verbosity == logging.DEBUG: |
686 | 686 | console.print_exception() |
|
0 commit comments