Re: Exception messages -> application? - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Exception messages -> application?
Date
Msg-id 20080404221440.GB6096@merkur.hilbert.loc
Whole thread Raw
In response to Exception messages -> application?  (Frank Miles <fpm@u.washington.edu>)
List pgsql-general
On Fri, Apr 04, 2008 at 12:02:20PM -0700, Frank Miles wrote:

> I have a moderately DB-ignorant question: is there a "built-in" way for an
> application to receive the message emitted by a RAISE .... in a PgSQL function?
>
> Context: I have a moderately complex application (in python, using psycopg2)

psycopg2 does a pretty good job of converting any PostgreSQL
side exceptions into Python exceptions which are then
getting raised in your Python code. Unless you explicitely
silence/catch PG exceptions inside your plpgsql code you
should be seeing them turn up in Python.

There's a bunch of arguments on the Python exception raised.

try:
    ...
except TheExceptionType, e:
    print dir(e)

might help with that.

Also, you may need to fiddle with the PG client logging
settings (in postgresql.conf) which control what level of
detail of error information is getting sent to the client in
the first place.

BTW, are you talking about RAISE EXCEPTION or RAISE NOTICE ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

pgsql-general by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: Direct access to GIST structure
Next
From: Ralph Smith
Date:
Subject: Re: psql: FATAL: role "xyz" is not permitted to log in