Exceptions in Unity
Exceptions are problems that happen during the execution of a program that will result in the program abnormally ending. As you are creating your programs you will need to handle these exceptions if you want your code to work correctly. There are two different types of exceptions.
The first are checked exceptions. These exceptions are syntax errors that occur when the code is being compiled. This type of exception will cause the red squiggly lines under your code.
The second type is unchecked exceptions. These exceptions are logical errors in your code that occur during execution. These errors are not as easily caught because they do not cause the red squiggly lines under your code.
One way to handle these exceptions is the use a try-catch block. The try-catch block works by trying to execute a block of code. If an exception happens it will be caught and a different block of code is executed. This will catch any exceptions and allow the program to continue to execute.