Collect shipping and email address. Reject a purchase if either is incorrect.
Errors, or exceptions, happen all the time in programming. You can’t escape them. But you can handle them gracefully.
In exception handling, two sets of instructions are defined. The first set is executed, and if an exception occurs, the first set is stopped and the second set of instructions is executed.
In this example,
- The first set is “collect shipping address”, “collect email address”
- The second set is “reject the purchase”
If any errors occur in executing the first set—maybe the address is incorrectly formatted, or fake—it is stopped and the second set is executed.
These statements are useful if you know an exception may occur in a set of instructions but you don’t know in which one, or you expect the same exception might occur in multiple, sequential instructions.
Instructions
Set the shipping and contact information, then click through the exception structure.
What happens when you select a fake address and a real email?
What happens when you select a real address and a fake email?