Re: Can I map "raise XXX" to some custom python exceptions? - Mailing list psycopg

From W. Matthew Wilson
Subject Re: Can I map "raise XXX" to some custom python exceptions?
Date
Msg-id BANLkTikOuawtXKvOokuUvJBDRMuSyO+W7Q@mail.gmail.com
Whole thread Raw
In response to Can I map "raise XXX" to some custom python exceptions?  ("W. Matthew Wilson" <matt@tplus1.com>)
Responses Re: Can I map "raise XXX" to some custom python exceptions?
List psycopg
On Sun, Jun 19, 2011 at 1:02 PM, Dan Halbert <halbert@halwitz.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@tplus1.com
http://tplus1.com

psycopg by date:

Previous
From: "W. Matthew Wilson"
Date:
Subject: Can I map "raise XXX" to some custom python exceptions?
Next
From: Daniele Varrazzo
Date:
Subject: Re: Can I map "raise XXX" to some custom python exceptions?