Also another option to make it user friendly that I’ve used in the past - Custom Error Handling
You could implement this in addition to the suggestion from @david.wylie
from anvil import set_default_error_handling
from anvil.js import window
def error_handler(err):
if isinstance(err, anvil.server.SessionExpiredError):
alert(
'Your session has timed out. Please refresh the page to continue',
title='Session Expired' ,
buttons=[('Refresh Now', None)],
dismissible=False
)
try:
anvil.server.reset_session()
except:
window.location.reload()
else:
alert(err.args[0], title="Error")
# or raise err
set_default_error_handling(error_handler)