Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Python Error message Date: Fri, 5 Aug 2016 01:51:04 +1000 Lines: 18 Message-ID: References: <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de paZCy5rswA6f0vVpqHQ6jgZM8jnuRk268uf78QvbzDhg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'except:': 0.07; 'subject:Error': 0.07; 'cc:addr:python-list': 0.09; 'wrong,': 0.09; 'exception': 0.13; '"your': 0.16; "(i'm": 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guessing': 0.16; 'here).': 0.16; 'keyerror': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'exceptions': 0.22; 'am,': 0.23; 'header:In-Reply- To:1': 0.24; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'catching': 0.29; 'print': 0.30; 'up.': 0.32; 'continuing': 0.32; 'instead,': 0.33; 'skip:j 20': 0.33; 'received:google.com': 0.35; 'skip:p 30': 0.35; 'possible': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'expect': 0.37; 'anything': 0.38; 'skip:p 20': 0.38; 'goes': 0.39; 'application': 0.39; 'chrisa': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=NojlT6WuU2MS2o4yYjBrXhiT4IV/saB/7wSPsJV6c88=; b=hWh7TQiiXqcoGQdlokFtV3WuztVRxse5IPIU1/hgxiqHhI4tL2Id/zWLUAM8Et79UF AYqGfdNlJUY/bHTqZIJhZAGo0IIbjQd6C/jl7E1r6HInEQN9iqP2FhWB6aJl/7C06rei H+I6IRoJZ2KcHbOtagGlHtPhAdOAH3WLcEEsNClrYNPu9da7K1Sjtet5Ah0Vel3oN15F UlXRtNRuCYxXayyfSzQNi0racuPYVS3XSzSviK9g+0CgDCPQRyj70nV+Unx2/40YQujp pUaMhbrVQNu3k2oRW/eujHa3hneFJo1IOLSOIav88wRz4/2zbMcL+2BkifF8wr/v8jUe uvjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=NojlT6WuU2MS2o4yYjBrXhiT4IV/saB/7wSPsJV6c88=; b=drbobV1w9XG1hkeDb04JaK2DqDakiEA4Dy7ZjAMxvZ8DEqwyj9cjXitfMVJf1xuheK 4cXZkyKbiCwSFlXE4FVpq4Q5STuKRwQsf76Y3dR09ThM/j+i402QgjngpfIA3RTpjkun G36Th0xIHlmvq112uRv0W9JAPYZN5IYzDe87UysUdFeVy44V+WJhXEJ13Q19fiXbt4i8 JksevpA8AWQ/Mp7m8MEHFyIQ3u+67MspgSirF1NlzZd6fIiP3IO+5J36wnzS/F1WOXDf BkgWXEAbACzev/UExpUo7ux3njErLQcyaWCpfPK2HZD6QfwGo7a4MmAqD40PlhK+RdOH PFCA== X-Gm-Message-State: AEkooutKhnz1gvZ6RA/GurG9bA/wMSp8rqi1e8Aekdvr+Fu24vFDCzh+4LOX8gzXFpxEq7tq6E0DM3fG1q0d+A== X-Received: by 10.28.50.199 with SMTP id y190mr29592374wmy.61.1470325865206; Thu, 04 Aug 2016 08:51:05 -0700 (PDT) In-Reply-To: <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> Xref: csiph.com comp.lang.python:112333 On Fri, Aug 5, 2016 at 1:31 AM, GBANE FETIGUE 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