On 07.03.2012 7:54, James Miller wrote:
On 7 March 2012 16:43, Jonathan M Davis<jmdavisp...@gmx.com>  wrote:
On Tuesday, March 06, 2012 19:27:35 Andrei Alexandrescu wrote:
On 3/6/12 7:04 PM, Jonathan M Davis wrote:
On Tuesday, March 06, 2012 18:19:23 Jose Armando Garcia wrote:
Fatal and Critical are exactly these continence functions... To
reiterate. fatal will always assert and critical will always throw. It
is impossible for the user to disable these things.

No, because they affect the log level. The concept of throwing and the log
level should be _completely_ separate.

Why?

Because the level that you log something at and what you want to do in terms
of exceptions aren't necessarily related at all. It could easily be that you
want to log something and then do some series of operations before throwing -
even if the log level is the most severe level, and you intend to throw an
Error to kill the program. And as others have pointed out, you might want to
log a series of messages. Having std.log throw on the first one makes it so
that you can't log any others.

std.log shouldn't be declaring _any_
exception types unless they're related to setting up the logging (_none_
which relate to functions which log).

Why?

Because as others have asserted, logging should not affect program flow. It's
printing out messages to a log, which doesn't necessarily have _anything_ to
do with throwing exceptions. It's merely for providing information about what
the program is doing. If you have it throwing exceptions - _especially_
exceptions which are specific to it - you're conflating two separate concepts:
logging to a log file and having the program report errors. They _can_ be
related, but they often aren't.

And when you _do_ throw an exception, why on earth would anyone want a
LoggingException (or whatever std.log would call its exception type)? You want
an exception which relates to what went wrong, not what threw it. The fact
that you logged a message before throwing is incidental. Nothing that catches
the exception is going to care.

- Jonathan M Davis

Surprisingly, I agree with the idea that fatal and critical shouldn't
throw, or at least shouldn't throw by default, maybe a configuration
option would allow for that functionality. Logging probably shouldn't
affect program flow.

Its possible that I may need to log a "critical" error, then do some
graceful shutdown.

Exception is a graceful shutdown, as it calls destructors & finally blocks while unrolling the stack.


In my opinion, critical and error should /not/ throw by default,
however they should be able to get an optional Exception to throw, if
that is appropriate behavior.

--
James Miller


--
Dmitry Olshansky

Reply via email to