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

From: "W(dot) Matthew Wilson" <matt(at)tplus1(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Can I map "raise XXX" to some custom python exceptions?
Date: 2011-06-19 15:21:09
Message-ID: BANLkTimE2oG_9o7sgLy=wj76v5KHiWApgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)tplus1(dot)com
http://tplus1.com

Responses

Browse psycopg by date

  From Date Subject
Next Message W. Matthew Wilson 2011-06-19 17:45:24 Re: Can I map "raise XXX" to some custom python exceptions?
Previous Message Daniele Varrazzo 2011-06-14 10:23:18 Re: autocommit and Django