Skip site navigation (1) Skip section navigation (2)

Re: Can I map "raise XXX" to some custom python exceptions?

From: "W(dot) Matthew Wilson" <matt(at)tplus1(dot)com>
To: Dan Halbert <halbert(at)halwitz(dot)org>, psycopg(at)postgresql(dot)org
Subject: Re: Can I map "raise XXX" to some custom python exceptions?
Date: 2011-06-19 17:45:24
Message-ID: BANLkTikOuawtXKvOokuUvJBDRMuSyO+W7Q@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
On Sun, Jun 19, 2011 at 1:02 PM, Dan Halbert <halbert(at)halwitz(dot)org> wrote:

> Is it that you don't just want to raise your own exceptions manually, e.g.:
>
>   try:
>        cursor.execute("...")
>    except dbconn.InternalError, ex:
>        if ... :
>            raise OutOfStockException(...)

Yeah, this is what I'm doing now.  But there's a good chance that
something is going to get mapped to the OutOfStockException when it is
really a completely different kind of exception, like maybe I forgot
to set a non-null column.

So, really, I want to be able raise specific exceptions within
postgresql, and then define how those are converted to python objects.

Maybe I need to verify that postgresql supports custom exceptions.

Matt


-- 
W. Matthew Wilson
matt(at)tplus1(dot)com
http://tplus1.com

In response to

Responses

psycopg by date

Next:From: Daniele VarrazzoDate: 2011-06-20 14:03:42
Subject: Re: Can I map "raise XXX" to some custom python exceptions?
Previous:From: W. Matthew WilsonDate: 2011-06-19 15:21:09
Subject: Can I map "raise XXX" to some custom python exceptions?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group