Skip to content

Commit

Permalink
Method should always be available
Browse files Browse the repository at this point in the history
  • Loading branch information
Garulf committed Jan 25, 2024
1 parent 95b9f1b commit fa85194
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pyflowlauncher/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def add_methods(self, methods: Iterable[Callable[..., Any]]):
self.add_method(method)

def add_exception_handler(self, exception: Exception, handler: Callable[..., Any]):
self._handlers[exception.__class__.__name__] = handler
self._handlers[exception] = handler

def __call__(self, method: str, *args, **kwargs):
try:
return self._methods[method](*args, **kwargs)
except Exception as e:
handler = self._handlers.get(e.__class__.__name__, None)
handler = self._handlers.get(e, None)
if handler:
return handler(e)
raise e
# raise e
2 changes: 1 addition & 1 deletion pyflowlauncher/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def settings(self) -> dict:

def run(self) -> None:
request = self._client.recieve()
method = request.get('method')
method = request["method"]
parameters = request.get('parameters', [])
feedback = self._event_handler(method, *parameters)
# Inject settings if changed
Expand Down

0 comments on commit fa85194

Please sign in to comment.