Handle 404 error in code


I’ve recently deployed a Streamlit app to Cloud Run where I’m getting the following 404 error after the Cloud Run timeout is reached:

This specific error is a known issue when deploying Streamlit to Cloud Run (see here) but I wanted to know if it’s possible to handle this 404 error in code and instead show a friendlier message to the user (e.g. “Your connection has timed out, please refresh the page to start again.”)? If not, I think this could be a nice feature to add to Streamlit.