Thursday, 30 January 2014

Week 4: Exceptions

In the previous week, we learned to write exception classes and try statements. We were able to implement this knowledge into this week's exercise, where we wrote our own exceptions (E2Error, E2OddError) for our try statements. I had a lot of trouble understanding the three components of a try statement and in which order they execute. Because of this, I had to do a lot of research before figuring out how to complete the exercise. This frustrated me because the examples I found online were not completely relevant to the tasks we were given, but in the end, I managed to figure it out. A try statement includes three components: try, except, and finally. The code under the try clause is executed first, and if an error is detected, it will execute the except clause of whichever error occurred. The finally clause executes whether or not an error occurs.

Another area that I had difficulty in was writing exception classes, or rather, implementing them into my except clauses; however, I was able to learn how to do this, which is why this is one of my biggest achievements this week.

No comments:

Post a Comment