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

Поиск
Список
Период
Сортировка
От W. Matthew Wilson
Тема Can I map "raise XXX" to some custom python exceptions?
Дата
Msg-id BANLkTimE2oG_9o7sgLy=wj76v5KHiWApgw@mail.gmail.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: autocommit and Django
Следующее
От: "W. Matthew Wilson"
Дата:
Сообщение: Re: Can I map "raise XXX" to some custom python exceptions?