What are WebError's?

W
ebError is an exception object which is used to raise and catch errors / exceptions. For example, if the client asks for information about a non-existent course, the page which usually displays the information, raises a WebError exception. This exception is then caught and an error page is displayed to the user. As soon as the exception is raised the code execution is aborted and control is transferred to the exception handler. For example, suppose you have locked some tables in the database and then encounter a bad condition, you need to make sure you unlock the tables before raising the exception. In python this can be done using a finally block as follows:


try:
  lock tables
  calculate
  if bad condition:
      raise WebError ("bad_condition","Error Message")
  continue with regular stuff
finally:
  unlock tables

This ensures that the tables are unlocked irrespective of whether an exception occurred or not.