How to use pretty_errors module in streamlit?

pretty_errors is a good error deal module
it can show the error friendly and simply

after import pretty_errors module, the error information is still show the old style
reload app still can not change the error show style.

Is there a way let pretty_errors work with our greate streamlit app?

Hey @BeyondMyself !!

The pretty_error module is designed to work with Flask applications and is not explicitly compatible with Streamlit.

Streamlit uses Tornado as its default web server, which has its own error handling mechanism. However, if you are running your Streamlit application using a custom web server such as Flask or FastAPI, you may be able to use pretty_error with some modifications to the code.

In general, pretty_error provides a way to format error messages in a more human-readable way, which can be helpful for debugging. To use it with Streamlit, you would need to integrate it with your custom web server code and ensure that the error messages are returned in the expected format for pretty_error to work correctly.

Alternatively, Streamlit provides its own error reporting functionality via the st.exception() method, which can be used to display error messages to the user in a user-friendly format. This method can be used to catch exceptions raised by your code and display them in a Streamlit app.

Also you can take a look at st.error if that matches your use case.
Sorry for such a late reply.

1 Like