Safely call a plugin method, catching and logging exceptions.
(plugin: MetadataSourcePlugin, method_name: str)
| 61 | |
| 62 | @contextmanager |
| 63 | def maybe_handle_plugin_error(plugin: MetadataSourcePlugin, method_name: str): |
| 64 | """Safely call a plugin method, catching and logging exceptions.""" |
| 65 | if config["raise_on_error"]: |
| 66 | yield |
| 67 | else: |
| 68 | try: |
| 69 | yield |
| 70 | except Exception as e: |
| 71 | log.error( |
| 72 | "Error in '{}.{}': {}", plugin.data_source, method_name, e |
| 73 | ) |
| 74 | log.debug("Exception details:", exc_info=True) |
| 75 | |
| 76 | |
| 77 | def _yield_from_plugins( |
no test coverage detected