The error exception is raised when an illegal expression is passed to a function. It has the form try:

... match statement except error,e: . . . handle the error

The optional argument to the except statement is a variable to catch tie argument sent to the raise statement at the time of the error. This car be used in the handler statement to alert the user to a dislike.

... search("[[[","This is a test") ... except error,e: . . . print e

The output is

Unmatched [] in expression.

Was this article helpful?

0 0

Post a comment