exception psycopg.Error from psycopg2 to psycopg 3 - Mailing list psycopg

From Paolo De Stefani
Subject exception psycopg.Error from psycopg2 to psycopg 3
Date
Msg-id 11dedb1fce0dbbd6f125736347685fd5@paolodestefani.it
Whole thread Raw
Responses Re: exception psycopg.Error from psycopg2 to psycopg 3
List psycopg
Hi all

Porting my program from psycopg2 to psycopg 3 i found another different 
behaviour

This SQL code inside a function:

RAISE EXCEPTION 'Error wrong database' USING HINT = 'You need to use a 
different database', ERRCODE = 'PA002';

is catched in python code with:

try:
    <execute sql function>
except psycopg.Error as er:
     raise PyAppDBError(er.sqlstate, er)

With psycopg2 er.sqlstate is set to 'PA002' in psycopg3 is set to None

Is this an expected behavour ? Is there a way to get the error code in 
psycopg3 like it is available in psycopg2 ?
Or maybe Am I doing something wrong ?

Thanks


-- 
Paolo De Stefani



psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: psycopg-pool 3.1 released
Next
From: Daniele Varrazzo
Date:
Subject: Re: exception psycopg.Error from psycopg2 to psycopg 3