Introducing Gradio ClientsJoin us on Thursday, 9am PST

Livestream

Alerts

You may wish to display alerts to the user. To do so, raise a gr.Error("custom message") in your function to halt the execution of your function and display an error message to the user.

Alternatively, can issue gr.Warning("custom message") or gr.Info("custom message") by having them as standalone lines in your function, which will immediately display modals while continuing the execution of your function. The only difference between gr.Info() and gr.Warning() is the color of the alert.

def start_process(name):
    gr.Info("Starting process")
    if name is None:
        gr.Warning("Name is empty")
    ...
    if success == False:
        raise gr.Error("Process failed")
```<p class='tip'><strong>✍️ Tip:</strong> Note that `gr.Error()` is an exception that has to be raised, while `gr.Warning()` and `gr.Info()` are functions that are called directly.</p>