Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109445

Re: Catch exception with message?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Catch exception with message?
Date Fri, 3 Jun 2016 18:25:18 -0600
Lines 20
Message-ID <mailman.139.1464999965.1839.python-list@python.org> (permalink)
References <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.com> <CALwzidnkqM72Zoyn_Rv5tBOEHrRPtT8vBGHqjNKveVkoPmgajg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de PW22XjlB2ufak9sq7KCmVAITcdiTfvK3wJobBOtlvVXg==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'cc:addr :python-list': 0.09; 'e.args[0]': 0.09; 'received:209.85.218': 0.10; 'exception': 0.13; '2016': 0.16; 'cc:name:python': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:exception': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'this.': 0.28; 'raise': 0.29; 'url:mailman': 0.30; 'generally': 0.32; 'url:python': 0.33; 'url:listinfo': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'url:mail': 0.40; 'subject:with': 0.40; 'different': 0.63; 'capture': 0.66; 'to:none': 0.91; 'subject:Catch': 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=m0ojwXumb+WtSiDMJLBHeIHfNZ92PC+Ot8mJkvozk58=; b=vF/wzTaxfN5iczrYujSCxGH2CnXIJGeAElTxT+OF3UumlQqqQrD1r8hNYAVrnX92k8 egRQ5p8TFhT+xQNReghUX6Yj2HBHBCYRv7MZZXNayVtZ16W7jHsHf1dwjTj7MRNpsyQQ wZucM48ZJu3Pdp6pyHBgs7NDHbSqDH2IlYeWChzEPcptkNZlsnKD4BbLRINb4A9pxkOO EDhFvfy1IzNeycmushWWMTMU2LR3LPBXpuB28U3pBnsqX/JBywophMr8gw7V9I3/QQWL Immwk/vOJKFOinzCN8i6OZAXXu8dVj1zE6LuKCDrVrtfvphNKXwZTlOYAmrKsqZKFqIg 78XA==
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=m0ojwXumb+WtSiDMJLBHeIHfNZ92PC+Ot8mJkvozk58=; b=QEt8BMo6R9AvrVeeLvhTQC82RP5Btj5AY0UnNCjcpeTqF9xb7SzUrNM2L+xmMnZJ7k t6U46xebp8zYxKjdjhiTZnFg1O+K/75aoshwWRSLfS114/IIFYYwQkZ/3MhGZauQQbdi vLIt1E75RF31PJWA8/xnQUS/G2wFrWUEHJsHb5ax0wz3I7pB5Nyn+CytrqImXLGxAhei RTOtmlj5RRzu59n6dj4oMA0x5BdfQD0N7ai9ID0sSUDV2ilDi2yzFN8pe2f17Zf0hVHZ Zr4ieQJGjuemG62EDt7Qyxs2K00mw1irhihemtHemuFUjzt1wFA/mdmgjTfitobTaJFw ooJg==
X-Gm-Message-State ALyK8tK7DEbc1mzvl0jA+QnyoSAdpVstvdMaKBfdalWzWb5ilvNuoHvQM6gitq7GVhqbbWXi71mNBkkQtzN3hQ==
X-Received by 10.157.2.174 with SMTP id 43mr3223454otl.11.1464999958083; Fri, 03 Jun 2016 17:25:58 -0700 (PDT)
In-Reply-To <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CALwzidnkqM72Zoyn_Rv5tBOEHrRPtT8vBGHqjNKveVkoPmgajg@mail.gmail.com>
X-Mailman-Original-References <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.com>
Xref csiph.com comp.lang.python:109445

Show key headers only | View raw


try:
    something
except Exception as e:
    if e.args[0] == message_of_interest:
        handle_it
    else:
        raise

On Fri, Jun 3, 2016 at 5:14 PM, Piyush Verma <114piyush@gmail.com> wrote:
> Generally we catch exception using
> except Exception as e:
>
> But sometimes, we see same type of exception is present with different
> message.Is there a way to capture same exception with message
> filtering? Please help me to do this.
>
> Regards,
> ~Piyush
> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Catch exception with message? Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-03 18:25 -0600

csiph-web