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

From W. Matthew Wilson
Subject Can I map "raise XXX" to some custom python exceptions?
Date
Msg-id BANLkTimE2oG_9o7sgLy=wj76v5KHiWApgw@mail.gmail.com
Whole thread Raw
List psycopg
Right now, I have some triggers that can raise integrity constraint violations.

And in python, I have code like this:

    try:
        cursor.execute("...")
    except dbconn.InternalError, ex:

I'm working on code that handles buying and selling physical goods.
It would be nice to have exceptions that are more relevant to that
stuff -- I mean I want exceptions like "this good is not in the
warehouse" or "this good isn't available during that window of time".

Is this possible?

How do I map database exceptions to interesting exception types in python?

Matt


--
W. Matthew Wilson
matt@tplus1.com
http://tplus1.com

psycopg by date:

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