Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sorts': 0.04; 'subject:module': 0.04; 'exception,': 0.07; ':-)': 0.07; 'exception.': 0.09; 'pm,': 0.11; 'exception': 0.12; 'message-----': 0.14; 'wrote:': 0.14; '(gnu/linux)': 0.16; '----- begin': 0.16; '-----end': 0.16; 'from:addr:kb1pkl': 0.16; 'from:name:corey richardson': 0.16; 'gnupg': 0.16; 'hash:': 0.16; 'message-id:@aim.com': 0.16; 'mrab': 0.16; 'pgp': 0.16; 'richardson': 0.16; 'sha1': 0.16; 'skip:1 60': 0.16; 'url:enigmail': 0.16; 'url:mozdev': 0.16; 'comment:': 0.19; 'header:In-Reply-To:1': 0.22; 'define': 0.26; 'pass': 0.27; 'signed': 0.27; 'raise': 0.29; 'class': 0.29; 'to:addr:python- list': 0.32; 'url:docs': 0.33; 'things': 0.33; "isn't": 0.34; 'using': 0.34; 'received:192': 0.34; 'received:192.168.0': 0.35; 'there': 0.35; 'header:User-Agent:1': 0.35; 'received:192.168': 0.37; 'url:python': 0.37; 'andrew': 0.38; 'url:org': 0.38; 'version:': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'how': 0.39; 'skip:h 20': 0.60; 'received:172.29.41': 0.84; 'skip:d 60': 0.84; 'subject:handle': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mx.aol.com; s=20110426; t=1305231638; bh=90CbuF94wYw1LYGNrwxqjlNpbYl2/mUeO9ljtN+b5+I=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type; b=j8ED5WTjJkQOlvbS/xYO19ojjgh7X8iNgidLnsr/XULOsSoxb9wgdkqjFZArCCPCz gpsousfcdQLNHOB+Wsu4N684RAHPM7VsvhIHFKJbo8AnrhR/30lLMmSK/0spKo5ThI t4JahF4B0EhX9wHBcahhJnbGLCquTqj/rneOsPfk= Date: Thu, 12 May 2011 16:20:13 -0400 From: Corey Richardson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre 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> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit x-aol-global-disposition: G X-AOL-SCOLL-SCORE: 0:2:455027584:93952408 X-AOL-SCOLL-URL_COUNT: 0 x-aol-sid: 3039ac1d29434dcc41156690 X-AOL-IP: 71.181.22.109 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305231953 news.xs4all.nl 81482 [::ffff:82.94.164.166]:54728 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5257 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/12/2011 04:12 PM, 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. class HelloError(Exception): pass Of course, there are all sorts of other things you could do with your exception. http://docs.python.org/tutorial/errors.html#user-defined-exceptions - -- Corey Richardson -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJNzED9AAoJEAFAbo/KNFvp1uQIAKFaKyD1Q3RL7LGFSmnyRFTK 9XWRH3CSM9mOALccfQ8bUkrquol1fAqhrm4jyOW0scWmsJpRlcb6Rj4HtrmMQOuG DpsUzEZCTnT9Xk80OeTFbpWWBIVBkxdhCxCl75XAP22o5EjhHpgLyqoqMD+81BKH 5/JWAGRJx/9E4BvNWsxIUhb1jlz+XT4H1XykTE1UUOP0uZneWRJMs7P12WNiL2Ii HT0hEUhQc1eP1fJ5BqPB/6/B9q/KxTbN55hCq1VwwfRhgbaM4kR7Bekri7QUHGAK 1MKxRa1v+Co59y+ywAIH92L3wky3xNyFrUlFzK4AwYOnwRkVvUWw7vPG1iShE+k= =2+y6 -----END PGP SIGNATURE-----