| # 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. | |
| You can also 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. | |
| ```python | |
| 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") | |
| ``` | |
| Tip: Note that `gr.Error()` is an exception that has to be raised, while `gr.Warning()` and `gr.Info()` are functions that are called directly. | |