Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling for async observers #1783

Open
mdickinson opened this issue Mar 26, 2024 · 1 comment
Open

Add error handling for async observers #1783

mdickinson opened this issue Mar 26, 2024 · 1 comment

Comments

@mdickinson
Copy link
Member

For normal (synchronous) Traits observers, if an exception occurs then we execute Traits's exception handler, which by default simply logs the exception. The relevant code (or at least part of it) is here:

try:
self.dispatcher(handler, event)
except Exception:
handle_exception(event)

For asynchronous Traits observers as introduced by PR #1770, exceptions occurring in the observer are swallowed entirely, with no easy way to log the exception.

It would be useful to have the option to act on the exception in some way (for example, by logging). This would probably entail adding a Traits-specific wrapper around the coroutine to be executed.

@mdickinson
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant