Any way to peek at the exception currently being thrown?

kdevel kdevel at vogtner.de
Fri Jun 18 13:52:10 UTC 2021


On Friday, 18 June 2021 at 12:37:15 UTC, Steven Schveighoffer 
wrote:
[...]
> A transaction is an atomic change to the database. Let's say I 
> have 2 library types that have a `saveToDB` function. Each of 
> those might have multiple SQL statements they use, which I want 
> to be atomic.

What do you want to be atomic? The collection of SQL statements 
or the individual SQL statements?

> But I also might want to save both of them at once and have 
> *that* be atomic.

Okay, you cannot commit within your saveToDB method. So you must 
tell the computer when it should commit:

    obj1.saveToDB;
    obj2.saveToDB;
    tx.commit;

> Right now, I just put the transactions at the highest level, 
> and the types cannot enforce atomicity of their own storage.

They can, but they cannot enforce "*that*" atomicity from obove.

> Really, there are 2 problems here. One is that I want to avoid 
> having to type out those 3 lines.

??

> The other is that I want to implement some sort of re-entrant 
> transactions, which can be done already without language help.
>
> But something like a `scope(failure) ~this()` mechanism might 
> be useful for the first problem.

Sure.


More information about the Digitalmars-d mailing list