GIS4102 - Module 3 - Debugging and Error Handling
For this module, it was tasked of us to fix and modify script templates. Specifically, syntax errors were placed within 3 different scripts. For the first script, two syntax errors were placed and it was simple to fix and get the script to run which the results are shown below.
The script should print out the names of all fields that were within the data of a folder we were given, which is successfully shown here.
For the second script, several more errors were created and running the script was a little more complicated. It was most difficult personally to have the correct file paths within the script so that the correct data could be accessed as the fixed script should display all of the layers within a project on ArcGIS Pro. The key to this module was to have very organized file paths and recognize what type of data the script was trying to access. Eventually the script ran successfully and the results are shown below.
For the final script, I had to identify the errors in the script, but rather than fixing them, I had to use try-except statements to get the script to run. To help with the process I created a flowchart of my process for the script as there was an 'A' and 'B' part. The flowchart is shown below.
It may look like a fairly simple process, but in reality had me looping back to make sure the try and except blocks were in the correct spots. For block 'A', I had to make the script run, while also showing the error that occurred when it did run. For block 'B', the script had to fully function, printing out the name, data source, and spatial reference of each layer in the project. This was similar to script 2, so with added steps and placing the try and except blocks where needed. The results is shown below.




Comments
Post a Comment