XML Output: libxo - provide single API to output TXT, XML, JSON and HTML

Simon J. Gerraty sjg at juniper.net
Fri Aug 1 05:04:41 UTC 2014


On Thu, 31 Jul 2014 21:36:43 +0000, Poul-Henning Kamp writes:
>>sbuf looks like a simple case, returning either ENOMEM or the
>>error code from the flush function.  libxo can keep a "there's
>>been an error" flag that the user can retrieve, but all the
>>details of what's gone wrong would be lost.  Or it can buffer
>>the contents of warning messages and deliver it to the caller.

>The point here is one of API design, and experience has shown
>that either error-handling is convenient or it doesn't happen.
>
>I don't see the libxo case being any different from sbuf
>in this respect, in fact I see it being almost even more
>important because the readers are non-humans.

The libxo case can be complicated by the structured output.
If you have emitted

<something>
 <here>
  <might>
   <fail>

and then you encounter an exception, even if you output a nice

<exception type="ENOMEM">sorry about that</exception>

your peer may not cope unless you also close all the open elements:

</fail></might></here></something>

etc.  
Of course I wouldn't be surprised if the lib already handles all that ;-)



More information about the freebsd-arch mailing list