Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'exception,': 0.07; ':-)': 0.07; 'exception.': 0.09; 'exception:': 0.09; 'from:addr:python': 0.09; 'subclass': 0.09; 'pm,': 0.11; 'exception': 0.12; 'wrote:': 0.14; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mrab': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'header:In-Reply-To:1': 0.22; 'received:84': 0.25; 'define': 0.26; 'pass': 0.27; 'raise': 0.29; 'class': 0.29; 'to:addr:python-list': 0.32; "isn't": 0.34; 'header:User-Agent:1': 0.35; 'reply- to:addr:python.org': 0.35; 'andrew': 0.38; 'to:addr:python.org': 0.39; 'how': 0.39; 'reply-to:no real name:2**0': 0.72; 'header :Reply-To:1': 0.72; 'subject:handle': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlEHAIVBzE3Unw4S/2dsb2JhbACYAY14d8kDhhUElCOKQg Date: Thu, 12 May 2011 21:26:55 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Proper way to handle errors in a module References: <4DCC318E.7020809@gmail.com> <4DCC3421.9070007@mrabarnett.plus.com> <4DCC3F37.3010904@gmail.com> In-Reply-To: <4DCC3F37.3010904@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 11 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305232018 news.xs4all.nl 81483 [::ffff:82.94.164.166]:55437 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5259 On 12/05/2011 21:12, Andrew Berg wrote: > On 2011.05.12 02:25 PM, MRAB wrote: >> You can raise an exception wherever you like! :-) > If I raise an exception that isn't a built-in exception, I get something > like "NameError: name 'HelloError' is not defined". I don't know how to > define the exception. Define it as a subclass of Exception: class UnknownBirdError(Exception): pass