Add error handling for frame processor module loading

pull/800/head
cattodotpy 2024-11-21 21:29:05 +08:00
parent b7d9889565
commit c4c459972a
1 changed files with 7 additions and 4 deletions

View File

@ -19,10 +19,13 @@ FRAME_PROCESSORS_INTERFACE = [
def load_frame_processor_module(frame_processor: str) -> Any:
frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}')
for method_name in FRAME_PROCESSORS_INTERFACE:
if not hasattr(frame_processor_module, method_name):
sys.exit()
try:
frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}')
for method_name in FRAME_PROCESSORS_INTERFACE:
if not hasattr(frame_processor_module, method_name):
sys.exit()
except ImportError:
print(f'Error: Could not load frame processor module "{frame_processor}"')
return frame_processor_module