Wednesday, June 4, 2025

Module 3 - Debugging and Error Handling

Figure 1: Results of Script 1



Figure 2: Results of Script 2


Figure 3: Results of Script 3
Figure 4: Flowchart for Script 3 - This flowchart denotes the process for creating the try-except statement in script three that allowed the full script to run regardless of existing errors. 



Module 3 introduced error handling in our scripts. Knowing about common errors and how to troubleshoot is essential to saving time while coding. A type of error, called exceptions, are errors that occur during run time and wreak havoc on your operation. A solution to these unexpected errors is using a "try except" statement that allows the script to run while exceptions are trapped and "handled". Part 3 of our assignment, denoted below, shows the process for using the try-except method for script 3. 


 Part 3: Make a code run even with errors


The try-except statement process was not nearly as tedious or as terrifying as previously imagined. When the first error occurred, a type error, I proceeded to write a try-except statement for that section. When that ran, another error came up, a name error. Then, I wrote another try except for that! After running that, another type error appeared! Yikes! Then it hit me; you can do an all-encompassing try-except statement for the whole block of code using the catch-all Exception class. The statement began right after defining aprx and right before the final print statement was processed.  

I had to recall the importance of indentation so that the try except statement recognized the complete block of code.

Once the code was run, part b ran with no issue. 


Overall, I really enjoyed this section of the class and see how useful this will become in the future. 


No comments:

Post a Comment

Module 5- Exploring and Manipulating Data

Figures 1-4: Creating a File geodatabase and copying data into it. Flow chart denoting the cradle to grave process of creating a file geodat...