Debugging and Error Handling
GIS5103 - GIS Programming - Module 3
Learning outcomes:
Demonstrate the ability to fix syntax errors and exceptions
Implement debugging procedures
Modify scripts to run with exceptions
Interpret script error messages
Identify correct usage of try-except statements
Implement debugging procedures
Modify scripts to run with exceptions
Interpret script error messages
Identify correct usage of try-except statements
This lab contained 3 scripts containing some of the most common types of errors and tested the knowledge of how Python works that we've learned thus far. This was our first application of the Try-Except statements covered in Chapter 7. This lab exposed us to several different types of error messages and gave us practice adding to scripts in order to make them run even when error codes are thrown. The 3 scripts used are described below:
Script 1:
Script 1:
This script first turns on labels and visibility for layers in a given document and then prints the layer info. This required trapping several exception using try expect throughout the script. My process is demonstated below for the second half of this third script:
- First run script without making and changes to find a starting point.
- Use error code as a clue, examine code and try to find where this issue is originating.
- Inset try and except clause and try running again. Catch an further errors.
- When stuck go back to the basics and make sure the data is where you think it is, it has what you think it does in it (examine in arcGISpro), double check version of python.
- Try, fail, repeat.
- Review Textbook, look up you tube explanations, revisit exercises, to see if you can apply it to the problem in the lab.
- Guess right. Celebrate functional code with a snack break.
- Try to figure out why that worked.
Design a logical model of a script using a flowchart
Comments
Post a Comment