Friday, July 25, 2014

GIS 4102 Module 9 Assignment: Debugging & Error Handling

Figure 1
First Script - List of Airports
Debugging and handling errors were emphasized in this week's module. Having experienced quite a bit of debugging my own scripts in this course, especially with syntax and using the technique of commenting out sections of code, this exercise and assignment were extensions of that but also included try-except statements. The first script, with results shown here, contained two relatively easy syntax errors which allowed the script to run after correction. A list of airports was printed as a result (Figure 1).


Finding the eight errors in the second script took longer. The errors in the second script included misspellings, incorrect punctuation, and arguments along with incorrect mxd and path names. Once corrected, the script printed out a list of layers in the data frame as shown in Figure 2.

Figure 2
Second Script - Layers in Data Frame
Although in retrospect it was relatively easy, the third script took the longest. This was due primarily to determining where to place the try-except statement which, once placed correctly, allowed the script to run through to completion with an error message being printed for Part A and select data frame properties being printed for Part B. These results are shown in Figure 3.

Figure 3
Third Script - Error Message and Specified Data Frame Properties 

The step-through mode of the debugger was quite helpful for this assignment. All the techniques for error and exception handling will be very useful in future assignments during the course and employment.

No comments:

Post a Comment