Displaying error messages is a simple way to let the user know that their input or action is not acceptable at the program’s current state. It can also help to catch all errors that may result from a block of code (in a try
) with a single error message to the user
Creating an Error Message
Simply raise a Python Exception
(or your own Exception
child class) to create a notification for users when they encounter an issue.
raise Exception("Put a user friendly error message here. Typically suggest an action or explain what the user may have done wrong")
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")
Ensure to raise the exception where appropriate in the Flow:
What to Expect
Expect the error to show up transiently as a 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.
Previous Article |
Next Article |