exception guidelines for launchpad - good idea?

David Allouche david at allouche.net
Thu Dec 8 11:32:23 GMT 2005


On Thu, 2005-12-08 at 16:26 +1100, Martin Pool wrote:
> I agree that it is a bad idea to catch TypeError except in very
> tightly-defined cases - e.g. when trying to convert a string to an int,
> as in the doc.
[...] 
> I don't see how that follows.  I'd say it's OK to raise TypeError or
> ValueError if you got the wrong type AND you don't expect callers to try
> to catch this, but rather that it will just indicate a bug.  There's no
> point subclassing TypeError.

You are saying essentially the same thing as I did earlier in the
discussion that lead to this coding guideline for Launchpad.

My proposal was:

        Please, let's never catch built-in exception types, except in
        very narrow try-except clauses around language constructs or
        standard library calls that raise them.
        
        As a corollary, never raise a built-in exception type, except
        when doing sanity checking and when the client code is not
        expected to treat that error condition in a specific way.

-- 
                                                            -- ddaa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051208/98ab596c/attachment.pgp 


More information about the bazaar mailing list