Skip to content

Commit

Permalink
Fix except-start cannot have return statements
Browse files Browse the repository at this point in the history
  • Loading branch information
linkous8 committed Apr 24, 2024
1 parent ff28154 commit efb315b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions servo/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,20 @@ async def run(self) -> List[EventResult]:
**self._kwargs,
)

except* servo.errors.EventCancelledError as error:
# Return an empty result set
servo.logger.warning(
f'event cancelled by before event handler on connector "{connector.name}": {error}'
)
return []
except ExceptionGroup as eg:
if any(
(
isinstance(se, servo.errors.EventCancelledError)
for se in eg.exceptions
)
):
# Return an empty result set
servo.logger.warning(
f'event cancelled by before event handler on connector "{connector.name}": {eg}'
)
return []
else:
raise

# Invoke the on event handlers and gather results
if self._prepositions & Preposition.on:
Expand Down

0 comments on commit efb315b

Please sign in to comment.