Mercurial > libervia-pubsub
diff sat_pubsub/pgsql_storage.py @ 332:31cbd8b9fa7f
pgsql: node creation now return error.NodeExists in case of unique violation, and InvalidConfigurationOption else
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 03 Apr 2017 00:24:34 +0200 |
parents | e93a9fd329d9 |
children | 57a3051ee435 |
line wrap: on
line diff
--- 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));