How to stop streamlit when it detectan error?


As mentioned in the title, how to stop streamlit app from running when it detects an error,
something like st.stop that does stop the app when the entered data does not fit the requirements.

Thank you in advance

Github Issue:

1 Like

Hey @amineHY,

Could you provide a bit more information on what you’re trying to do or perhaps a code snippet?

In the snippet below the report stops executing after the exception.

import streamlit as st

slider = st.slider('slider', 0, 100, 25, 1)

raise Exception('error')

1 Like

Thank you @Jonathan_Rhone,
Your answer is more then enough, I thought there there is a streamlit way of doing it.

1 Like

@amineHY: If you want to halt execution without visually showing the exception, an undocumented feature is that you can also throw a StopException (more details) which will also silently halt the script.