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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse psycopg by date

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