public inbox for [email protected]
help / color / mirror / Atom feedFrom: Rory Campbell-Lange <[email protected]>
To: Daniele Varrazzo <[email protected]>
Cc: [email protected]
Subject: Re: Plans for 2.8
Date: Thu, 4 Oct 2018 14:55:01 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+mi_8auWr+u4DwLGnu3JOu=jhMAV_8OPnMtMuXOr+0iMN5LgA@mail.gmail.com>
References: <CA+mi_8auWr+u4DwLGnu3JOu=jhMAV_8OPnMtMuXOr+0iMN5LgA@mail.gmail.com>
On 04/10/18, Daniele Varrazzo ([email protected]) wrote:
> The feature I'm the most excited about (and worried about its
> reception) is to raise a different exception for every postgres error
> message (see #682) . For instance `SELECT * FROM wrong_name` will
> raise `UndefinedTable` rather than `ProgrammingError`. Currently
> handling a specific exception requires catching a broader class and
> looking at the pgcode:
>
> try:
> cur.execute("lock table %s in access exclusive mode nowait" % name)
> except psycopg2.OperationalError as e:
> if e.pgcode == psycopg2.errorcodes.LOCK_NOT_AVAILABLE:
> locked = True
> else:
> raise
>
> This can become a much more natural:
>
> try:
> cur.execute("lock table %s in access exclusive mode nowait" % name)
> except psycopg2.errors.LockNotAvailable:
> locked = True
>
> The error classes are generated automatically from Postgres source
> code and are subclasses of the previously existing ones, so existing
> code should be unaffected. I'd be happy to have input about the
> feature and suggestions before releasing it.
Hi Daniele
The greater depth of exception reporting looks great to me, particularly
if they are subclasses of the existing ones.
Regards
Rory
view thread (8+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Plans for 2.8
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox