Module 4 - Debugging and Error Handling
This week's assignment had us learning about debugging and error handling
For script 1 we had to find the two errors within the script in order for it to run successfully. The two errors here involved making "fc" all lowercase and ensuring that line 15 read the correct variable. Instead of reading "- for fields in field:" it should read "-for field in fields".
Script 2 was a little more tedious in finding the eight errors that occurred within this script. There were a number of different kinds of errors we had to identify.
I had a lot of trouble with this in the assignment and unfortunately wasn’t able to correctly have the error message in Part A and have the script run successfully in Part B. I was able to determine the error and allow both Part A and part B to run successfully by including the mxd variable in Line 14 “mapdoc = arcpy.mapping.MapDocument(). I then added a try-except statement asking the script to remove any exceptions that would not allow Part B to run successfully. Once I ran the script however my results in Part A were correct, I received a green error message, however Part B showed an error message that lyrlist had not yet been determined.