Federico Heinz <fh...@vi...> wrote:
> Thanks for the prompt answer! Indeed, this answers my question, but of
> course it prompts another :-)
>=20
> On Thu, 2003-09-25 at 09:46, Sebastien Bigaret wrote:
> > 2. It then opens a transaction in the db, and sends the necessary SQL
> > statements (INSERT/UPDATE/DELETE) in this transaction. If any error
> > occurres when these sql statements are executed, the whole
> > transaction is rolled back.
> > 3. It commits the transaction. Here again, if an error occurs at the
> > DB-level, the transaction is rolled back.
>=20
> I assume that it also raises an exception at this point. Which exception
> is this, and what information does it contain? (a pointer to the
> relevant code is enough if you don't feel like writing a long answer).
Two different exceptions can be raised
- ValidationException, which you already know,
- GeneralAdaptorException (raised by AdaptorChannel)
- and <embarrassed> hmm, well,... RuntimeError... </embarrassed>
The relevant code is in ObjectStoreCoordinator's method
saveChangesInEditingContext(). I *know* the exceptions should be
better handled --I can still remember when I put the RuntimeError, I
was finalizing the whole code underneath saveChanges() and didn't want
to spend some time thinking of exceptions... Then it remained as is.
I'm also quite sure, although I did not check, that
GeneralAdaptorException is swallowed and mutated into a RuntimeError.
The good news is that I never encountered such errors in any of the
projects that are still alive. However, if in your environment you
have, for example, a network that may cause db-connections to be
randomly dropped, or specialized triggers/validation mechanisms that
are only coded on the SQL side, then you'll probably need something
better than a RuntimeError.
This is on the TODO list, obviously. And I'm open to any suggestions to
define the exceptions hierarchy.
-- S=E9bastien.
|