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


Groups > comp.lang.python > #109466

Re: Catch exception with message?

From Piyush Verma <114piyush@gmail.com>
Newsgroups comp.lang.python
Subject Re: Catch exception with message?
Date 2016-06-04 12:09 +0530
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>

Show all headers | 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