This week, we covered debugging and error handling in codes. We had three different codes that we had to find and fix errors in.
For the first code, we had to fix two errors. I was able to spot the capitalization error before even trying to run this code. When I ran it at first, I realized that I had my data in an additional subfolder so I got an additional third error in the code. I moved the files into the main Data folder and things went better from there.
In the third script, we weren't supposed to fix the error but isolate it with a try except statement so that the other portion of the code would work. This part gave me quite a time trying to figure out how much of the code to bypass. I definitely just kept trying it in different places. In the end, I realized the answer was there all along in the error message: Line 13. It was far more of part a than I expected! The indents also got tricky to sort out how many each line needed.
Here's what the flowchart of the code with the statement. Part A of the code tries to run the code in the script to print the layer names. However, if it gets an error, it skips this code and prints the error message instead.

No comments:
Post a Comment