class shiny.types.SilentException#

Throw a silent exception.

Normally, when an exception occurs inside a reactive context, it’s either:

  • Displayed to the user (as a big red error message)
    • This happens when the exception is raised from an output context (e.g., shiny.render.ui())

  • Crashes the application

This exception is used to silently throw inside a reactive context, meaning that execution is paused, and no output is shown to users (or the python console).


#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *
from shiny.types import SilentException

app_ui = ui.page_fluid(
        "Enter text to see it displayed below the input",

def server(input: Inputs, output: Outputs, session: Session):
    def txt_out():
        if not input.txt():
            raise SilentException()
        return "Your input: " + input.txt()

app = App(app_ui, server)