Lab 12: Error Handling with Exceptions
In this lab you will:
- Write exception classes
- Catch and handle exceptions
You are given an IntStack class that has plenty of error checking. However, whenever an error occurs, the program exits. This is bad because you don't want IntStack to handle the problem — you want to handle the problem in main().
The general rule is that only main() should decide if the program should exit. For example, if the stack is empty when we try to pop a value, main may know a way to handle it and can avoid exiting.