No matter how well-designed and implemented a program is, errors will occur eventually. These may be caused by incorrect code or by circumstances outside the program’s control, such as the user entering incorrect values or a printer not being connected to the network.
Different languages handle errors in different ways, but Visual Basic, C#, C++, and Java use a similar approach. The basic syntax in pseudocode is as follows:
Try statements... Catch
<exception>statements... Finally statements...
The statements after the Try keyword are the ones that might cause an error.
If an error occurs, the program executes the statements after the Catch keyword. (If no error occurs, the program skips those statements.) The variable