Multipage app: Redirect to custom errorPage in case of data validation error


i’ve a multipage application with three pages, called “Dashboard” and “Errorpage”:

Furthermore, there exists one global component (as singleton), which loads, validates and returns the data.

Whenever the users enters the Dashboard, the DataManager is getting callled validate_data(). If validition state has an error (NOK), the user shall be redirected from Dashboard to Errorpage.

The function validate_data() needs to be called after every page visit on /dashboard, since there’s a very frequent data import and errors can occur / go at any time

How can i do this in dash?


Hi @Robert2

The easiest way might be to consider the error page as “utility” rather than an actual page registered with dash.register_page

so in

import Errorpage

def layout():
    if validate_data() == "NCK"
         return Erorrpage.layout
    html.Div(... # dashboard layout ...
1 Like