{"guide": {"name": "alerts", "category": "additional-features", "pretty_category": "Additional Features", "guide_index": 4, "absolute_index": 17, "pretty_name": "Alerts", "content": "# Alerts\n\nYou 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.\n\nYou 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. \n\n```python\ndef start_process(name):\n gr.Info(\"Starting process\")\n if name is None:\n gr.Warning(\"Name is empty\")\n ...\n if success == False:\n raise gr.Error(\"Process failed\")\n```\n

\n \n \n \n \n \n Tip:\n \n Note that `gr.Error()` is an exception that has to be raised, while `gr.Warning()` and `gr.Info()` are functions that are called directly.\n

\n \n\n", "tags": [], "spaces": [], "url": "/guides/alerts/", "contributor": null}}