XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Poul-Henning Kamp
phk at phk.freebsd.dk
Thu Jul 31 21:36:45 UTC 2014
--------
In message <201407312130.s6VLUFSP097778 at idle.juniper.net>, Phil Shafer writes:
>Poul-Henning Kamp writes:
>>Can I point discreetely at sbuf(3)'s accumulative error handling
>>and suggest that libxo does something similar ? That way applications
>>only need to check for errors once, rather than after every single
>>call to every single function in the libxo library.
>
>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.
We can afford to dedicate a buffer of a reasonable size for that
purpose if we need to.
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.
libxo should latch on error like libsbuf, and valid output
should only be emitted if no errors were encountered during
production.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the freebsd-arch
mailing list