Notification system for error messages

Could you recommend me an approach how to add a notification system to an existing Dash app? The main purpose for the notification system is to report errors (Python exceptions) that might occur inside of any callback function.

In principle I am trying to re-implement the In-App Error Reporting Dev Tool.

For the UI, I would like to use dash-mantine-components Notification component. But I am also open to other proposals.

My app is a fairly large multi-page app. The app is heavily using pattern-matching callbacks. It uses @app.long_callback() as well as manually implemented async. callbacks.

For the callback logic, I was thinking that a decorator function that would do the error handling and would wrap my existing callbacks might be a good approach. But I am not sure how I would deal with the fact that the decorated functions (my callback functions) can have various numbers of outputs.

I am aware of dash-extensions LogTransform feature. I am hesitating to try to use it because

  1. I am not sure how well dash-extensions work with the latest versions of Dash.
  2. My app uses the @app.long_callback() syntax and I prefer not to update to background callbacks (at least for the time being).

I’ll by thankful for any guidance! :slight_smile:

1 Like

Hello @sislvacl,

I actually have an issue open for this:

I typically like to send myself/IT team of when something breaks.

What I’ve come up with is something like this:

def alertError(subject, error):
    msg = ... subject
    msg.body = error
    mail.send(msg)

And then I send the error to the team. The error is normally traceback.format_exc()

def callback(...):
    try:
        ## code
        return valid response
    except:
        alertError(callback error, traceback.format_exc()
    return 'There was an error, IT has been notified'