Errors cannot always be avoided. If you create programs that are prepared for errors and can react to them, you save time and nerves. When a tool returns an error message, ArcPy generates a system error or exception. In Python, you can provide a set of structures and methods that handle exceptions. These errors must also be caught and handled appropriately. The following sections explain some procedures to introduce you to the basics of error handling in Python.
Exceptions in software development are used to ensure that certain situations are handled separately. Certain exceptions are thrown when a problem is detected and allow error handling anywhere in the code.