Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #112333
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Python Error message |
| Date | 2016-08-05 01:51 +1000 |
| Message-ID | <mailman.163.1470325867.6033.python-list@python.org> (permalink) |
| References | <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> <CAPTjJmpAT48Unx-agLi=kb3RNQeyPGmWxU1J5iccfNHEu7zvqg@mail.gmail.com> |
On Fri, Aug 5, 2016 at 1:31 AM, GBANE FETIGUE <bemen77@gmail.com> wrote: > try: > parsed_response = json.loads(response) > print "Your applicationId is: " + parsed_response[u'applicationId'] > version_id = parsed_response[u'versionId'] > print "Your versionId is: " + version_id > except: > print 'Seems the named application already exists!' > print 'Seems the named versionId already exists!' > This is a very bad idea. You're catching every possible exception and printing out the same message for all of them. And then continuing blithely on. Instead, catch ONLY the exceptions you really expect to be seeing (I'm guessing KeyError here). If anything else goes wrong, let the exception bubble up. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python Error message GBANE FETIGUE <bemen77@gmail.com> - 2016-08-04 08:31 -0700
Re: Python Error message Chris Angelico <rosuav@gmail.com> - 2016-08-05 01:51 +1000
Re: Python Error message Steven D'Aprano <steve+python@pearwood.info> - 2016-08-05 01:56 +1000
Re: Python Error message Igor Korot <ikorot01@gmail.com> - 2016-08-04 12:09 -0400
Re: Python Error message Chris Angelico <rosuav@gmail.com> - 2016-08-05 02:14 +1000
Re: Python Error message MRAB <python@mrabarnett.plus.com> - 2016-08-04 17:19 +0100
Re: Python Error message Terry Reedy <tjreedy@udel.edu> - 2016-08-04 15:36 -0400
Re: Python Error message Chris Angelico <rosuav@gmail.com> - 2016-08-05 05:53 +1000
Re: Python Error message dieter <dieter@handshake.de> - 2016-08-05 09:03 +0200
csiph-web