Working with Exceptions
Learn what are exceptions and how to work with them.
We'll cover the following...
What is an exception?
An exception (short for exceptional event or exceptional condition) is an error or an unexpected event that occurs while a program is running. It’s caused by a condition in the software where the program has reached a state where it can no longer run.
There are many reasons we can get an exception. One example could be if our program needs to read data from a file, but the file is not where it’s supposed to be. Since the program has a reason to read the data from this file, a failure to do so will put the application in a state where it can no longer guarantee that its output will be correct. The best option, in this case, is just to halt the program and give back an error that hopefully ...