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


Groups > comp.lang.python > #57486

Re: Re-raising a RuntimeError - good practice?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <robotsondrugs@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.064
X-Spam-Evidence '*H*': 0.87; '*S*': 0.00; 'cpython': 0.05; 'practice,': 0.07; 'exception,': 0.09; 'windows': 0.15; 'err:': 0.16; 'guessing': 0.16; 'redundant,': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; "i'm": 0.30; 'received:10.0.0': 0.31; 'yes.': 0.31; 'except': 0.35; 'received:google.com': 0.35; 'right?': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'received:10.0': 0.36; 'received:10': 0.37; 'message-id:@gmail.com': 0.38; 'handle': 0.38; 'to:addr:python- list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'catch': 0.60; 'mentioned': 0.61; 'new': 0.61; 'simply': 0.61; 'here': 0.66; 'freebsd': 0.84; 'subject:good': 0.84; 'victor': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=T8gymCg/3C1XSeqeDDrv+xkfPmHyyrqxWvskwvBw9Nc=; b=0A2noWjLjbJfeVzvJqcE5ilkA62J4kkblwP3LKPl1yZIreK6HBHbfy2YZjvQcfO0gM WKu7STcJtVlQdOdHkmvsXrs4BaVHAoY7xWSnexT97gnbC6am4rJM3MEzj3wylnmQZUg7 AYEpc7FpforwPx0v10mWInTm9c5ktjHe/t0cZ/BElf6sTa7ec+l+8W7NjPaalHCudc2d 4wcYcmBSSZcefscR5E+wzDrfuzTh9vGCCRCfpmK7EDWYEGev2T5I71lhIsdWAFIqnlYm 3WZmdl94H9nFGqGeDz1iQDCNf0n+TY9y0KZRFgpJ3kJJZYT1TCa909btFIdpaAq8AAcp Yt9A==
X-Received by 10.50.127.197 with SMTP id ni5mr236657igb.54.1382663856718; Thu, 24 Oct 2013 18:17:36 -0700 (PDT)
Date Thu, 24 Oct 2013 20:17:24 -0500
From Andrew Berg <robotsondrugs@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
To python-list@python.org
Subject Re: Re-raising a RuntimeError - good practice?
References <670cb7a6-f8e9-4e3d-95a0-95728f8dd815@googlegroups.com> <mailman.1439.1382589791.18130.python-list@python.org> <c40fd572-d344-4d48-8c37-4fbbcc60efa3@googlegroups.com>
In-Reply-To <c40fd572-d344-4d48-8c37-4fbbcc60efa3@googlegroups.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.1493.1382663859.18130.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382663859 news.xs4all.nl 15951 [2001:888:2000:d::a6]:37662
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57486

Show key headers only | View raw


On 2013.10.24 20:09, Victor Hooi wrote:
> Also, @Andrew Berg - you mentioned I'm just swallowing the original exception and re-raising a new RuntimeError - I'm guessing this is a bad practice, right? If I use just "raise"
> 
>         except Exception as err:  # catch *everything* 
>             logger.error(err) 
>             raise 
> 
> that will just re-raise the original exception right?
Yes. However, if you are doing logging higher up where you actually handle the exception, then logging here is redundant, and you can simply
eliminate the try/catch block completely.

-- 
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 10.0

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


Thread

Re-raising a RuntimeError - good practice? Victor Hooi <victorhooi@gmail.com> - 2013-10-23 20:23 -0700
  Re: Re-raising a RuntimeError - good practice? Steven D'Aprano <steve@pearwood.info> - 2013-10-24 04:34 +0000
  Re: Re-raising a RuntimeError - good practice? Andrew Berg <robotsondrugs@gmail.com> - 2013-10-23 23:42 -0500
    Re: Re-raising a RuntimeError - good practice? Victor Hooi <victorhooi@gmail.com> - 2013-10-24 18:09 -0700
      Re: Re-raising a RuntimeError - good practice? Andrew Berg <robotsondrugs@gmail.com> - 2013-10-24 20:17 -0500
        Re: Re-raising a RuntimeError - good practice? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-25 02:30 +0000
  Re: Re-raising a RuntimeError - good practice? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-25 00:44 -0700

csiph-web