Function Call based exception handling
| A |
You gave me -100 for a course number
Another possible situation: An error has occurred. But some special cases does not require user intervention, the script should be able to take care of it.
In either of these situations you need a function call based exception handling. In this case the exception is raised using
raise WebError ("bad_crse_num()",self.args)
When the exception handler sees a "()" at the end of the first argument, it assumes that you want to handle the exception in your own function. The name of the function is handle_bad_crse_num(self,page,message), i.e. function name is got by prepending the first argument with "handle_". The function should take three arguments: self (since it is a method of the Display class), page and message. The page argument contains the page object which contains the error page. The message argument is whatever was passed in the second argument in your raise statement. In this case it is self.args. Since arguments in python can be any type, you can send as much information as you want to your exception handler, by properly packing it and unpacking it.

