On Thursday, 26 March 2015 at 11:23:34 UTC, Andrej Mitrovic wrote:
Granted it's not the best example out there, but I think it has
potential. Thoughts?

Your example will print the exception message 2 (or 3) times. Is this really necessary?

I've found that

scope(failure) log("Failure while transmogrifying " ~ victim ~ ":");

is often sufficient. Assuming the exception will be caught and logged to the same output as the log line above, it'll show up right before the exception details, thus giving the needed context.

What is your use case for only logging specific exception types?

It would be nice if we could add arbitrary information to in-flight exceptions themselves. E.g. a nicer way to do something like this:

 try
   transmogrify(victim);
 catch (Exception x)
 {
x.msg = "Failure while transmogrifying " ~ victim ~ ":\n" ~ msg;
   throw x;
 }

I've also tried a different approach, using chained exceptions:

https://github.com/CyberShadow/ae/blob/master/utils/exception.d#L68-L91

Reply via email to