# HG changeset patch # User Goffi # Date 1491171874 -7200 # Node ID 31cbd8b9fa7f263d67531090a9285520e40b8788 # Parent e93a9fd329d97fdc7d9a4f91ef81714e10a75b67 pgsql: node creation now return error.NodeExists in case of unique violation, and InvalidConfigurationOption else diff -r e93a9fd329d9 -r 31cbd8b9fa7f sat_pubsub/pgsql_storage.py --- a/sat_pubsub/pgsql_storage.py Sun Mar 26 20:58:48 2017 +0200 +++ b/sat_pubsub/pgsql_storage.py Mon Apr 03 00:24:34 2017 +0200 @@ -225,8 +225,12 @@ recipient.userhost() if pep else None ) ) - except cursor._pool.dbapi.IntegrityError: - raise error.NodeExists() + except cursor._pool.dbapi.IntegrityError as e: + if e.pgcode == "23505": + # unique_violation + raise error.NodeExists() + else: + raise error.InvalidConfigurationOption() cursor.execute(*withPEP("""SELECT node_id FROM nodes WHERE node=%s""", (nodeIdentifier,), pep, recipient));