What to do when there is an error at runtime


In a Java program, when the program is executing and there is an error, the compiler stops the program and throws an exception. Is there something similar to this in Unity? I mean, in case my player reference is null or something similar, I want to some how now that it is null and to quit the game. I do not want the user to be able to continue playing if something is broken in the game. Anything already implemented in Unity or should I have a method that is called every time there is an error to quit the application?


C# uses the try-catch-finally and throw methods