[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python or Perl for a Debian maintainance project?



Hi, Andrew Suffield wrote:

> My criticisms were of using exceptions to avoid handling errors, which was
> the proposed "advantage".

Actually, I didn't say that at all. On the contrary, exceptions are there
to _handle_ errors.

The advantage of exceptions IMHO is that you can handle errors _once_, at
the point where it's convenient to do so / they are shown to the user
/ whatever makes sense for your application, instead of being forced to
add explicit error-checking code to every single line that could
conceivably throw an error.

Plus, even if you handle the error, you can still get an exact backtrace
to the place where it occurred, so you can store it / package it in a bug
email / whatever.

Plus, you can wrap critical code in cleanup handlers without changing any
of the rest of your error handling logic. Example:

...
    f=create_a_file(name)
    try:
        do_something_insanely_complicated(f)
    except:
        os.unlink(f)
        raise

What this does is fairly obvious. What's more, this is a fairly standard
Python idiom which quickly becomes second nature (IMHO).

Now try the same thing in Perl.

-- 
Matthias Urlichs



Reply to: