ERROR HANDLING
==============

In Elisa, the error handling is done using exceptions.

What an exception is: *Exceptions indicate a broken contract*

"One other way to think about exceptions, which may give you more insight into
when you should use them, is that exceptions indicate a "broken contract." One
design approach often discussed in the context of object-oriented programming
is the Design by Contract approach. This approach to software design says that
a method represents a contract between the client the caller of the method)
and the class that declares the method. The contract includes preconditions
that the client must fulfill and postconditions that the method itself must
fulfill."

excerpt from http://www.javaworld.com/javaworld/jw-07-1998/jw-07-techniques.html


For those like me who do not like bla bla, some concrete examples are available
in the following.


RANDOM EXAMPLES
---------------

FIXME: needs some more work.

1st example
-----------

using return values:

if toto():
    do my stuff
else:
    error handling


it is not necessary to do that:

try:
    a = toto()
except:
    error handling


this might be sufficient:

a = toto() -> exception raised
a.titi

* using exceptions is less or equal work than checking return values


2nd example
-----------

try:
    toto()
except:
    pass

* never catch all the exceptions (unless there is a good justification)
* never do nothing in the exception treatment code


3rd example
-----------

try:
    toto()
except Exception:
    do stuff

* be very specific when you catch exceptions: be sure to catch only the
  exception you want to treat
