chain of exceptions, next method

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Mar 6 23:23:22 UTC 2024


On Wednesday, March 6, 2024 6:06:34 AM MST kdevel via Digitalmars-d-learn 
wrote:
> On Saturday, 10 September 2022 at 08:48:39 UTC, Andrej Mitrovic
>
> wrote:
> > [...]
> > I wish the compiler would rewrite scope(failure) to use chained
> > exceptions. Otherwise any exceptions thrown within
> > scope(failure) can end up losing information about what was the
> > original exception that was thrown.
>
> Ran into this issue with the following ordering bug:
>
>     auto tmpfilename = fn.dup ~ ".XXXXXX\0";
>     int fd = mkstemp (tmpfilename.ptr);
>     scope (failure) remove (tmpfilename); // bug:
>     if (fd == -1)
>        throw new Exception (strerror(errno).to!string);
>
> The error thrown was
>
>     Failed to remove file ...
>
> Is there any work in progress to chain the exceptions in
> scope(failure)?

If anything, I think that it's been decided that chained exceptions were a
mistake. So, if things go in any direction with them, it's likely to be
towards removing them, not doing more to support them.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list