exception guidelines for launchpad - good idea?
Robert Collins
robertc at robertcollins.net
Wed Dec 7 23:19:20 GMT 2005
On Wed, 2005-12-07 at 09:38 -0500, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> | https://wiki.launchpad.canonical.com/ExceptionGuidelines
> |
> | That documents the recently decided guidelines for exception handling in
> | launchpad. I think they are sane and we should adopt them for bzr.
> |
> | They dont have a great deal of rationale behind them, but I'm happy to
> | add rationale as needed if folk have questions.
>
> It looks okay, but the stuff on TypeError isn't clear to me. I think
> it's quite reasonable to throw TypeError if we get an argument of the
> wrong type. And since we are writing a library, the rationale about
> writing an app doesn't hold.
The point about not writing a general purpose library is that its better
to die than to swallow a bunch of random exceptions and have bugs
undiagnosed. In bzr's case the same applies - we dont want bugs to sit
around for long periods of time because they are caught by erroneously
robust code.
The thing about exceptions is who will catch them and why.
Firstly, do you see why catching TypeError is bad? Catching TypeError
is bad because (due to python shortcomings) using the wrong number of
parameters - plain broken code - is conflated with some constructor
errors in built in types. This makes it possible to catch exceptions you
dont want to (because broken code should be exposed).
Building on that, if we are not catching TypeError anywhere because of
this confusion, we *could* raise TypeError when we wanted a unicode
string but got a normal string, but we would be furthering that
confusion.
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- 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/784b1673/attachment.pgp
More information about the bazaar
mailing list