<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jun 18, 2013, at 12:03 PM, Laurens Van Houtven <_@lvh.io> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 18, 2013 at 8:22 PM, Glyph<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;">I would say that if we want to percolate this information up to the caller, there should be a ConnectingCancelled exception that is a subtype of the previous exception type.<div dir="auto"></div></div></blockquote><div><br></div><div>Doesn't that mean we'll have many subclasses that mean that something was cancelled?<br><br>If I didn't take backwards compatibility into account, I would say that composing the original exception into a new CancellationError (or something) exception would be preferable. Would you agree that it would be preferable? (Again, not taking compatibility into account -- I'm trying to get compatibility vs niceness of API to face off against each other. Personally, I think it's enough of a change in functionality to warrant a chance in ways a function can fail, but there's no point in even having that argument if there's no consensus that the composed way would even be better...)<br></div></div></div></div></div></blockquote><div><br></div><div>I agree that it would be preferable, but I don't see how it's possible without making Exception itself composeable.</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> After all, if it's interesting that the operation was cancelled, presumably it's interesting <i>at what stage</i> the operation is cancelled.</div><div><br></div><div>IIUC that would work the same with composition as inheritance :)<br></div></div></div></div></div></blockquote></div><br><div>Unfortunately inheritance is built into the way Python handles exceptions.  In fact in this case you almost want *multiple* inheritance, so you can say 'except CancelledError:' or 'except ConnectionError:' as appropriate.  :-(</div><div><br></div><div>The one saving grace here is that not a whole lot of useful logic can live on the exception objects, so there's a limited amount of opportunity for getting oneself into trouble.</div><div><br></div><div>Please prove me wrong, though.</div><div><br></div><div>-glyph</div><div><br></div></body></html>