On Saturday, 24 May 2014 at 17:55:07 UTC, Ali Çehreli wrote:
On 05/24/2014 10:09 AM, Tim wrote:
> I'm working on an application where I want log all exceptions
but I'm
> not sure what's the best way to realize that.
A common solution is to log it in the exception class'es
constructor. We even dump the backtrace with libunwind in our
C++ application.
But this only works for my own exceptions, right? I don't see any
way to log exceptions in the constructor for phobos-function
which are also able to throw exceptions.
However, you may quickly realize that not every thrown
exception is log-worthy. The reason is, e.g. a MyMissingFile
exception may not be important when there is a default action
to follow. No need to log in that case.
That's right. It's not necessary to log all exceptions but using
a global exception handler wouldn't prevent me from handling such
exception in my method so that no exception is generated. It
would be nice to have something like Exception, Warning and Info
to determine if it's necessary to log it.