pony
pony copied to clipboard
Can't catch pony.orm.core.TransactionIntegrityError
Hi,
I'm currently out of any idea. I have some issues with external data, which is not so dramatic for my data I want, but it causes a TransactionIntegrityError and I can't catch it, regardless whatever I do.
Example:
try:
MyModel(value1=value1, value2=value2)
except pony.orm.core.TransactionIntegrityError as exc:
print(f'Error: {exc}')
else:
db.flush()
db.commit()
From my point of view this syntax is correct, however, the exception is thrown anyway, it's not caught by the try/except block. I also exchanged pony.orm.core.TransactionIntegrityError
with Exception
for more general purpose, no effect.
Am I doing something wrong or what may be the reason?
Many thanks in advance, regards, Thomas
Is the exception being raised from inside the else
block? Try this
try:
MyModel(value1=value1, value2=value2)
db.flush()
db.commit()
except pony.orm.core.TransactionIntegrityError as exc:
print(f'Error: {exc}')