Debug and Error Handling Module 3

 In this week's lab we were given three scripts to understand debugging procedures and handle error messages. Debugging in Python is essential to improving the code quality and productivity. Understanding and handling error messages is important because it stops the programs execution of the script. Being able to read and interpret the error message is critical to identify the problem within the code. This project also incorporated pulling information from ArcGIS with a Python script.


The first script given had two errors that needed to be addressed. One demonstrated how Python is case sensitive and something need to be capitalized. The other had two words switched around causing Python not to understand what you were asking it to execute. The following image shows Python shell output of the successful script with the name of all the layers in the ArcGIS project.





The second script had multiple errors and exceptions throughout. The variable "filepath" had the incorrect file path, so it was changed to reflect the location in my folders. Another case sensitive issue was noted, as well as a spelling issue. The image below shows the Python shell output of the successful script of all layers in the ArcGIS project and it's spatial reference.


The third script had two parts with an error in the first part causing the script not to run. This introduced how to use a try-except statement into the script so that even with an error the whole script could run. The image below shows the Python shell output of the successful script with an error message and the information for the layers in the ArcGIS project. I have also included a flowchart to better visualize how I implemented the try-except statement into the script.







Comments

Popular posts from this blog

Intro to GIS - Lab1 Overview of ArcGIS

About me

Final - Bobwhite-Manatee Transmission Line