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


Groups > comp.lang.python > #109483

Re: Catch exception with message?

From Peter Pearson <pkpearson@nowhere.invalid>
Newsgroups comp.lang.python
Subject Re: Catch exception with message?
Date 2016-06-04 16:44 +0000
Message-ID <drgeqkFcclcU1@mid.individual.net> (permalink)
References <CAJV9OM_eDYJHsq1J7N9mYQEyqRsUR1S7LOJWZ8+XGEJ_h3CHYw@mail.gmail.com> <mailman.138.1464995679.1839.python-list@python.org>

Show all headers | View raw


On Sat, 4 Jun 2016 04:44:30 +0530, 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.

Just to make sure, . . . are you aware that "except Exception" is
generally not what you want to do, that you generally want to say
"except ValueError" or "except KeyError" or "except UnicdeDecodeError"
or something specific like that?  Maybe that's where to find the
specificity you seek.

-- 
To email me, substitute nowhere->runbox, invalid->com.

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


Thread

Catch exception with message? Piyush Verma <114piyush@gmail.com> - 2016-06-04 04:44 +0530
  Re: Catch exception with message? Steven D'Aprano <steve@pearwood.info> - 2016-06-04 12:38 +1000
  Re: Catch exception with message? Peter Pearson <pkpearson@nowhere.invalid> - 2016-06-04 16:44 +0000
    Re: Catch exception with message? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-04 16:39 -0700

csiph-web