When is this applicable?
- To let the user know that their input or action is not acceptable at the program’s current state
- To catch all errors that may result from a block of code (in a
try) with a single error message to the user
Simply raise a Python
Exception (or your own
Exception child class):
raise Exception("Put a user friendly error message here. Typically suggest an action or explain what the user may have done wrong")
to pop a notification for users when they hit the issue. Additionally, if you can raise a notification as part of a Python
try block as shown here.
try: # write your normal code here except XYZException as e: raise Exception("Put a user friendly error message here. Typically suggest an action or explain what the user may have done wrong")
What to Expect (Validation)
Raise the exception where appropriate in the Flow:
Except the error to show up transiently as a toast message in the bottom right or persist (until cleared by the user) in the drawer at the top right and seen by clicking on the bell.