Review of Jose Armando Garcia Sancio's std.log

Jose Armando Garcia jsancio at gmail.com
Sun Mar 11 22:24:29 PDT 2012


On Wed, Mar 7, 2012 at 4:31 AM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Tue, 06 Mar 2012 22:54:39 -0500, James Miller <james at aatch.net> wrote:
>
>> 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.
>
>
> I see this pattern emerging:
>
> try
> {
>   critical("Connection aborted!");
> }
> catch(LoggingException e)
> {
> }
>
> // do graceful shutdown
> ...
>
> throw SomeError("Connection aborted!");
>

Or you can just:

scope(exit) // do graceful shutdown

error("connection aborted");
throw SomeError("connection aborted");

Or better yet:

scope(exit) // do graceful shutdown
//...
logAndThrow!(Exception, Severity.error)("connection aborted");

> -Steve


More information about the Digitalmars-d mailing list