Hello there 👋

Thanks for stopping by! We use cookies to help us understand how you interact with our website.

By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.

Display an exception.

When accessing the app through localhost, in the lower-right corner of the exception, Streamlit displays links to Google and ChatGPT that are prefilled with the contents of the exception message.

Function signature[source]

st.exception(exception, width="stretch")

Parameters

exception (Exception)

The exception to display.

width (int or "stretch")

The desired width of the exception expressed in pixels. If this is "stretch" (default), Streamlit sets the width of the exception to match the width of the parent container. Otherwise, this must be an integer. If the specified width is greater than the width of the parent container, Streamlit sets the width of the exception to match the width of the parent container.

Example

import streamlit as st

e = RuntimeError("This is an exception of type RuntimeError")
st.exception(e)
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.