On Thursday, 2 October 2014 at 18:11:26 UTC, Marco Leise wrote:
How would I typically log an exception?
I thought of one line per exception in the chain plus a full
trace for the last exception in the chain.
So the messages would be like:
Initialization failed.
Could not load configuration.
File "~/.config/app/settings.ini" no found.
Stack trace (outer to inner):
_Dmain_yadda_yadda+120
Config.__ctor(…)+312
…
File.__ctor(…)+12
So far so good, but I'm stuck at this line of code (where `e`
is a Throwable):
error(e.msg, e.line, e.file, funcName, prettyFuncName,
moduleName);
I don't know how to get at the function and module name where
the exception was thrown. I know this stuff is part of the
symbolic debug information, but I would think it is a common
use case of a logger to log exceptions.
I guess that should be part of the Exception. I have no idea how
to get __FUCTION__ of and Exception from inside another function.
Is it? And if so, what do we want to do about it?