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)?

Reply via email to