Monday, June 5, 2023

Module 3: Debugging and Error Handling


Module 3 Debugging and Error Handling


This image is showing that for the first template of code I have found the two errors in the code and now the code is running. The code prints out the names of each field in the park.shp file.

This image shows the code working for the code template 2. This code had several errors and exceptions that I had to find and adjust the code. One example of the errors I encountered was that the file path that the original code had was looking for the file in the wrong file location and I had to locate where the file was in my files and correct that. This code prints out a list of layers for each data frame in the TravisCountyAustinTx.aprx.


This image shows the code running and working for the code template 3. This code we were told not to fix the errors, rather, we were supposed to use a try-except statement to trap the error and print out the error so that way the code wouldn't crash. The flowchart for how I setup the try-except statement is below to illustrate how the code would work if it encountered an exception or if there were no errors found it would print "Part A Successfully Completed". The code for template 3 prints out an error message in part A stating what the error is, part b prints the name, spatial reference, and scale for three data frames in the TravisCountyAustinTX.aprx.
Notes from this Module:
  • The try-except statement is like the if statement but can be more useful working over errors and handling them.
  • Error messages you receive in python can be very useful in figuring out where your code crashed, as well as, what the error type is. 
  • Using the ArcGIS website to see what useful features are already in python can be used in your code or even see if the feature is spelled wrong or if a letter is case sensitive. 




 

No comments:

Post a Comment

Module 7 Google Earth

 Google Earth For this week's lab we were tasked with creating a dot density map of south Florida in Google Earth. The map also includes...