Best way to implement proper error reporting

I have an app the does network request, which makes use of the great support for async event handlers.

However, network requests can fail, and what I don’t see is a great way to handle error messages.

I found modals in templates, but there I’m having a weird issue where the busy indicator keeps flashing and I also don’t want the header bar in my app. I have not yet figured out if there is a way to add a modal to a custom template?

I found there is an Alert panel, which I guess I could use. But I’m having issues again where the size of the app gets calculated incorrectly if I add it.

What would be ideal if you could just have a Parameterized with an Exception or something.

I would suggest using the notifications component being introduced in Panel 0.13.0, see a preview here: Notifications — Panel v0.13.0rc1

This is a side-effect of either running with --autoreload (which you should only do in development or related to a periodic callback.

1 Like

Seems neat, but doesn’t seem to work for me.
I installed

pip install panel==0.13.0rc1

I added

pn.extension('plotly', sizing_mode='stretch_both', notifications=True)
[...]
        except Exception as e:
            print(e)
            pn.state.notifications.error(str(e))
[...]
Simulator().panel().servable()

But it prints the exception without showing a notification.

This is not using any particular template, because as I said I’m not interested in the busy indicator, header or any other features offered by it.

I do plan to add a custom template soon to customize the CSS of my app, so if the problem is I need to add some magic area, that could be done.

[edit] uh I tried adding a roots.notifications area but apparently you need more trickery than that. Unfortunate. Is there a template that has notifications, no header, or one you can get rid of?