The try block
If youre inside a method and you throw an exception (or another method you call within this method throws an exception), that method will exit in the process of throwing. If you dont want a throw to exit the method, you can set up a special block within that method to capture the exception. This is called the try block because you try your various method calls there. The try block is an ordinary scope preceded by the keyword try:
// Code that might generate exceptions
If you were checking for errors carefully in a programming language that didnt support exception handling, youd have to surround every method call with setup and error testing code, even if you call the same method several times. With exception handling, you put everything in a try block and capture all the exceptions in one place. This means your code is much easier to write and read because the goal of the code is not confused with the error checking.