Adding Python exception handling structures (try/except/else)
Python has built-in exception handling structures that allows you to capture error messages that are generated. Using this error information, you can then display a more appropriate message to the end user and respond to the situation as needed.
Getting ready
Exceptions are unusual or error conditions that occur in your code. Exception statements in Python enable you to trap and handle errors in your code, allowing you to gracefully recover from error conditions. In addition to error handling, exceptions can be used for a variety of other things, including event notification and handling of special cases.
Python exceptions occur in two ways. Exceptions in Python can either be intercepted ...
Get Programming ArcGIS with Python Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.