I've built an app using the shinydashboard package that queries a database. The user selects the sql criteria to use (eg. age range, gender etc) and clicks a submit button. The returned table is then displayed along with some charts from the data. Sometimes when there is a connection error the app grays out and you have to reload the dashboard, select the filters again and re-submit.
To improve user experience, is there a way for the app/dashboard to automatically refresh on error so that it is usable and the query can be resubmitted by the user.
To programmatically restart the session, you can add
session$reload()
to the error condition of a tryCatch that wraps your sql query function. However, that will just restart the app and not requery - to do that you would need to build some backend tracking of the user and store session data which is possible but possibly overkill in your case. I would suggest instead of a reload, incorporate the tryCatch with the error condition being a
shiny::showNotification()
stating to the user that there was an unexpected error and to resubmit