Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'exception,': 0.07; 'python': 0.08; '21,': 0.09; 'exceptions': 0.09; 'hierarchical': 0.09; 'subclass': 0.09; 'subject:error': 0.10; 'exceptions.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ioerror': 0.16; 'surprising': 0.16; 'unhandled': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'aug': 0.24; "i'm": 0.27; 'host': 0.27; 'paul': 0.28; 'remote': 0.28; 'mode': 0.28; 'indicated': 0.29; 'message-id:@mail.gmail.com': 0.29; 'operations': 0.30; 'down,': 0.30; 'fails,': 0.30; 'sun,': 0.30; '(e.g.': 0.31; 'list': 0.32; 'it.': 0.33; 'to:addr:python-list': 0.33; 'certain': 0.35; 'unless': 0.36; 'connection': 0.36; 'instead.': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'etc.)': 0.39; 'subject:with': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; 'benefit': 0.66; 'dealing': 0.69; 'failure': 0.73; 'everything.': 0.84; 'remedy': 0.84; 'subject:... ': 0.84; 'subject:types': 0.84; '\xa0but': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=qRU+sLD+jUlt6F6iRJalo5n4PYHoeUPXuHkuUH4li4k=; b=Q03Q6Ig2DV3VFQ9rtHncL1knbTNqZLGVhUDYinMTo/14XgiUYdT9eVSXc6vAQMjMjz cDkf/Ikd7FSevHHfCTtyPSIjrlGk5o/ra4vGa+7qxriGCvOUffQvL81EXgEVpfuU+BJJ nIfd3suaWAFZRzd2NrQaCFzYjX8shCPHfcqzI= MIME-Version: 1.0 In-Reply-To: <7xty9ahb84.fsf@ruckus.brouhaha.com> References: <4e4ec405$0$29994$c3e8da3$5496439d@news.astraweb.com> <7xipprsxha.fsf@ruckus.brouhaha.com> <4e5015ad$0$29986$c3e8da3$5496439d@news.astraweb.com> <7xty9ahb84.fsf@ruckus.brouhaha.com> Date: Sun, 21 Aug 2011 20:17:59 +0100 Subject: Re: try... except with unknown error types From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313954283 news.xs4all.nl 23909 [2001:888:2000:d::a6]:52269 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11955 On Sun, Aug 21, 2011 at 7:26 PM, Paul Rubin wrote= : > I'm not sure what to do instead. =A0The exceptions I'm currently dealing > with happen when certain network operations go wrong (e.g. network or > remote host is down, connection fails, etc.) =A0The remedy in each case i= s > to catch the exception, log the error, and try the operation again > later. =A0But there's no guaranteed-to-be-complete list in the Python doc= s > of all the exceptions that can be thrown. =A0A new and surprising mode of > network failure can lead to an unhandled exception, unless you catch > everything. > A new and surprising mode of network failure would be indicated by a new subclass of IOError or EnvironmentError. If you catch one of those, you should catch it. That's the benefit of hierarchical exceptions. ChrisA