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


Groups > comp.lang.python > #109466

Re: Catch exception with message?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Piyush Verma <114piyush@gmail.com>
Newsgroups comp.lang.python
Subject Re: Catch exception with message?
Date Sat, 4 Jun 2016 12:09:19 +0530
Lines 28
Message-ID <mailman.147.1465022369.1839.python-list@python.org> (permalink)
References <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.com> <1465000939.1726478.627518305.3BB72ED4@webmail.messagingengine.com> <CAJV9OM_Vvb52oJM4KWCKNw7761TOD5s-v=8e3X=hP3dJi4e8+Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 1mYfRF1u+EddDWKWhCfkUwGAS5s7hlzvNNU42WvVC7jQ==
Return-Path <114piyush@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'exception.': 0.07; 'stack.': 0.07; 'cc:addr:python-list': 0.09; 'exception': 0.13; '2016': 0.16; 'description)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:exception': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'meant': 0.22; 'exceptions': 0.22; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'defined': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'yield': 0.27; 'this.': 0.28; 'skip:u 20': 0.28; "skip:' 50": 0.29; 'them?': 0.29; 'url:mailman': 0.30; 'option': 0.31; 'generally': 0.32; 'url:python': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'filter': 0.35; 'skip:" 50': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'url:mail': 0.40; 'subject:with': 0.40; 'your': 0.60; 'different': 0.63; 'capture': 0.66; 'apart': 0.70; 'case?': 0.84; 'distinguish': 0.84; 'warning.': 0.84; '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:to :cc; bh=/3XvJVRWm2MLAHr2SsGen6LoJ0iuPMF9zyGgSTpXD7Y=; b=kdJeK0Yk0iTdNBRJNPW9Syh+eSDzbS8k6nodoI7jAG/6exDtn/8xsbunOI7oxX+wak Kp7b/g+fhcY6GaAAfRHXrODLEs+TsE86SK8sF2RFjtZqIEIue5hHVINtrFWUCaDnN+Yq F0R1oSwkHIC2ma/4Pw8orUXA4LtuXeqdw/WbH3fLjgp9X6Axs8j1NQqYcHacAbp8q7Ff dnFo8y2QyziGKhlro6gI52qCwiUqcq+ybcJ/UG0IzMvwOo6JshIHuIre03I+ZP4ccL0y CAvc8a2pvVviOQgf6eQG5DBUXBBViPtXxwE9jlQx1SH0owMhPfUpSV4/VmmuRAOvnCaK Qb+w==
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:to:cc; bh=/3XvJVRWm2MLAHr2SsGen6LoJ0iuPMF9zyGgSTpXD7Y=; b=cCc2oyCBQMoYywWn31oqb3FoLQ8TW6Y4Ii3KVLhbQz4xFi1R/wjl7QNSfOU/WPvhLr je/5t+sTssEhu+U9tFGNf/l8BU4N6DsA63w11jVU+6vaG2mSc6tX6PLSJJPURjy8HWP1 bipgAKlJdwWlIQTouDIR43RuJFN8sVoL4+vAY1a62YB2CxdzJHYFyC7Y1/B8Sk16av73 5tTMhzI/jiBccPhXdm1DbWCE69kzd6a3iIGmsR+JoeVn3V3Tn2Bu6u8XEYMXpKQKzHxP YsA8OZmNxawi8ZSK5gMUpoBWGE4lqTgnvZZP+xKQg2XZyViDfBfywQF2R73jse5wi7mE eYFQ==
X-Gm-Message-State ALyK8tIhfBSvCt2Y4lewYy8KLs5zsFrgj+xK42EF10/+jYDt+CL8VhI34fw+wmXAE/QnkzmQm5oMoAtUE6vwtA==
X-Received by 10.31.156.198 with SMTP id f189mr3459199vke.11.1465022359937; Fri, 03 Jun 2016 23:39:19 -0700 (PDT)
In-Reply-To <1465000939.1726478.627518305.3BB72ED4@webmail.messagingengine.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 <CAJV9OM_Vvb52oJM4KWCKNw7761TOD5s-v=8e3X=hP3dJi4e8+Q@mail.gmail.com>
X-Mailman-Original-References <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.com> <1465000939.1726478.627518305.3BB72ED4@webmail.messagingengine.com>
Xref csiph.com comp.lang.python:109466

Show key headers only | View raw


Below is exception type and it is user defined exception. I do not see
error number in exception stack. What other option we can use as
filter in below exception apart from message?

UserDefinedException: User defined message: {}
#012  File "/opt/cio/lib/python2.7/site-packages/manager.py", line
1100, in create_from_abc
#012    yield self.create(x, name, description)
#012  File "/opt/cio/lib/python2.7/site-packages/manager.py", line
1132, in create
#012    'errors.create.type_not_supported.{0}'.format(abc['type']),


On Sat, Jun 4, 2016 at 6:12 AM, Random832 <random832@fastmail.com> wrote:
> On Fri, Jun 3, 2016, at 19:14, Piyush Verma 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.
>
> The message is meant to be human-readable, and may change without
> warning. Is there no other property on the exceptions you want to catch
> that can be used to distinguish them? (errno, perhaps?) What's your
> specific use case?
> --
> 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? Piyush Verma <114piyush@gmail.com> - 2016-06-04 12:09 +0530

csiph-web