GIS5103 - Module 3 - Debugging and Error Handling
For this week's module 3, we learned how to debug and handle errors when running scripts. 3 scripts were provided for us to fix. This module reinforce the ideas of running making small changes one line at a time for me. Indentation of codes were also important in script #3. Capitalization also matters a lot when writing into code, as not having the same capitalizations for variables could mean your script will not run.
For script 2, I had to rename the file path to match the .aprx that was provided to us. There was a lot of capitalization errors as variables doesn't match with each other. Some line was even missing a letter. A lot of this errors didn't require me to google as the IDLE suggested a lot of the spelling error correction.
For scripts 3 and, 2 I added, a “try:” statement at the very top of the script after the first print function. Then I had to indent a lot of the lines after to make the script work. I kept indenting each line of the code and running it each time until the IDLE successfully ran. I added the “except Exception as e:” after a lot of trials and error but I found it adding it at the very end of the script worked for me. I then used a print function to print out the error.




Comments
Post a Comment