psycopg2: proper positioning of .commit() within try: except: blocks
Karsten Hilbert
Karsten.Hilbert at gmx.net
Mon Sep 9 04:56:47 EDT 2024
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list:
> That code doesn't inspire much confidence in me. It's far too
> convoluted with too much micro-management of exceptions.
It is catching two exceptions, re-raising both of them,
except for re-raising one of them as another kind of
exception. What would you doing differently and how ?
> I would much prefer to have just *one* place where exceptions are
> caught and logged.
There's, of course, a top level handler which logs and
user-displays-as-appropriate any exceptions. This is code
from a much larger codebase.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
More information about the Python-list
mailing list