From 76baf543d8ff4fe13591ee9afc2db2738819d146 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sat, 23 May 2020 11:19:21 -0400 Subject: [PATCH] Improve RequiredEventNotFoundError message Signed-off-by: Christophe Bedard --- .../tracetools_analysis/processor/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tracetools_analysis/tracetools_analysis/processor/__init__.py b/tracetools_analysis/tracetools_analysis/processor/__init__.py index f6007ec..380e970 100644 --- a/tracetools_analysis/tracetools_analysis/processor/__init__.py +++ b/tracetools_analysis/tracetools_analysis/processor/__init__.py @@ -282,7 +282,7 @@ class Processor(): """Processor class, which dispatches events to event handlers.""" class RequiredEventNotFoundError(RuntimeError): - """When a trace does not contain one event required by an EventHandler.""" + """When a trace does not contain at least one event required by an EventHandler.""" pass @@ -380,12 +380,15 @@ class Processor(): ) -> None: event_names = self.get_event_names(events) # Check names separately so that we can know which event from which handler is missing + missing_events: Dict[str, Set[str]] = defaultdict(set) for handler in self._expanded_handlers: for name in handler.required_events(): if name not in event_names: - raise self.RequiredEventNotFoundError( - f'missing event {name} for {handler.__class__.__name__}' - ) + missing_events[handler.__class__.__name__].add(name) + if missing_events: + raise self.RequiredEventNotFoundError( + f'missing events: {dict(missing_events)}' + ) def process( self,