Is it possible to throw exceptions to generate modal dialog on the UI?

Hi All,

Let me preface this question with an explanation - yes, it can be done by setting up a Modal window and having multiple Output which triggers the Modal window to be displayed. But it seems very “non-pythonic”.

Is it possible to implement a custom exception class with some layout/message attribute fields so that we can inject a window pop-up when this custom exception is thrown?

We know this is already done in Dash internally since exceptions in the callback functions are caught and propagated to the UI via the developer tools in the bottom-right corner.

I too am hoping to find the answer to this question.

I suspect that the Pythonic way to do this could possibly involve decorators or custom Exception subclasses that inherit from the base Exception Python class.

My motivation for answering this question is to display a modal when ANY errors occur so that the user will know that an error has occurred, and what kind.

Hello @human42,

You may be able to leverage a websocket in order to accomplish this: