M3 - Debug & Error Handling

 Script 1

Objective: Fix errors in Mod3_Script1_Template.py to list field names from parks.shp.

Flowchart


Output for Script 1 After Corrections



Script 2

Objective: Fix errors in Mod3_Script2_Template.py to list layer names from TravisCountyAustinTX.aprx.

Flowchart


Output for Script 2 After Corrections


Script 3

Objective: Modify Mod3_Script3_Template.py to handle errors using try-except statements without fixing the errors.

Flowchart



Output for Script 3 After Try-Except Statements

In Mod3_Script3_Template.py, the script is divided into two parts: Part A and Part B.

Part A: This part of the script is intentionally left with an error to demonstrate error handling. Instead of the program crashing and not moving further, I used a try-except statement to catch any errors and print an error message. The error message while also print what went wrong before continuing on to Part B. This is a crucial aspect of debugging since it provides immediate feedback on issues within the code.

Part B: Despite the error in Part A, Part B runs successfully. It prints the name, data source, and spatial reference of each layer in the ArcGIS project. I also used a try-except block that allowed the script to function correctly even when one part encounters issues.













Comments

Popular posts from this blog

M1 - Python Environments & Flowcharts

GIS Map Projections

ArcGIS Pro Orientation