On 6/7/22 12:28 PM, frame wrote:
On Friday, 3 June 2022 at 23:40:50 UTC, Steven Schveighoffer wrote:
During the last beerconf, I wrote a short blog post about how `Error`
and `Exception` are different, and why you should never continue after
catching `Error`s.
I know the thematics but I still wonder why we only have
`scope(failure)` then? Anywhere where you will use this shiny thing with
a return statement will also catch any error that have occurred.
`scope(exit)` doesn't allow return statements, thus the only properly
clean design would be an additional `scope(exception)` guard.
My very common use of `scope(failure)` for my DB code:
```d
conn.exec("START TRANSACTION");
scope(success) conn.exec("COMMIT");
scope(failure) conn.exec("ROLLBACK");
```
This is hard to encapsulate into a type, as dtors only hook
`scope(exit)` essentially.
-Steve