Kinds of Errors
This lesson sheds light on different types of errors and explains how exceptions can be used to handle different types of errors.
We'll cover the following...
Kinds of errors #
We have seen how useful the exception mechanism is. It enables both the lower and higher-level operations to be aborted right away instead of letting the program continue with incorrect or missing data or behave in any other incorrect way. This does not mean that every error condition warrants throwing an exception. There may be better things to do depending on the kinds of errors.
User errors #
Some errors are caused by the user. As we have seen above, the user may have entered a string like “hello” even though the program has been expecting a number. It may be more appropriate to display an error message and ask the user to enter appropriate data again.
Even so, it may be fine to accept and use the data directly without validating the data upfront; ...