[DGD] Is Running Atomically.

bart at wotf.org bart at wotf.org
Sat Sep 24 23:19:47 CEST 2016


Traditionally, I've been sending all debug output to dgd's console, due to
atomic code mostly and the desire to keep all messages in the exact order in
which they were generated, but anyway, I don't think the kernel lib provides
an easy way to do get the error that was caught in the way you wrote your
example, and act on it. It has been quite some time since I looked at that
code, and I don't really use it myself, so I could be wrong on this.

Gurbalib does have a way to get you the error when writing the catch as you
did, see its caught_error() afun, which can also get you the error trace, not
just the message. 

But you can write something like this which will work regardless of what lib
you use:

string error;

error = catch( write_file(....) );
if( error ) {
   do something useful, you now have the original message and the error
(without trace)
}

The error you get from a write_file in atomic code is pretty explicit :-)

Bart.

On Sat, 24 Sep 2016 21:15:55 +0100, Gary wrote
> On 24/09/16 20:07, bart at wotf.org wrote:
> > If you just want to deal with the file writes in the logging code, you could
> > also simply catch() the write, and see what the error is, it will also tell
> > you you are running atomic so you can respond to that.
> > 
> > What I described is much more generic (without it requiring some dummy file to
> > try writing to as a test)
> >
> 
> I had considered using catch, but (and this could just be due to a lack
> of knowledge of DGD/its error handling on my part) that seemed to 
> hide non atomic errors in write_file.
> 
> Is there a way to know that the caught part of a catch triggered due 
> to an atomic error rather than any other error that write_file (or other
> code) may raise?
> 
> At the moment in my LOGD write_log function I'm doing (amongst other 
> code)
> 
>    if (! running_atomically())
>       write_file(SYSTEM_LOG_FILE, message);
>    else
>       driver->message(message);
> 
> The LOGD is currently quite bare bones and the above is just to 
> ensure log calls (mostly debug logs) are reported at least somewhere 
> if they're made during an atomic operation.
> 
> Whilst I can change that to:
> 
>    catch {
>       write_file(SYSTEM_LOG_FILE, message);
>    } : {
>       driver->message(message);
>    }
> 
> Is there any way to know what error has been caught? Then the
> redirection of message to stderr via the driver can be done just for
> failure to write during an atomic function.
> 
> As in the case of other errors, for example if write_file can fail 
> due to some disk i/o issue? I'd want to be reporting that specific 
> error via the driver rather than (or along with) the original log 
> message. Or allowing the error to go uncaught to later be handled by 
> atomic_error in the errord.
> 
> Is that possible?
> 
> Regards,
> 
> Gary
> 
> ____________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd


--
http://www.flickr.com/photos/mrobjective/
http://www.om-d.org/




More information about the DGD mailing list