Re: [xml] enhancing the error handling API



On Tue, Mar 18, 2003 at 12:56:27AM -0800, Aleksey Sanin wrote:
Stefan Seefeld wrote:
As a suggestion I would propose following change:

    Replace all
        xmlGenericError(..., msg,...)
    with
        xmlGenericErrorPlus(..., error_code, file, line, msg, ...)
    and provide new error context (callback) that'll be able
    to handle all the additional parameters (application can
    install application specific error callback).

  Well to be really clear, the goal would be to install logicall callback
through the XML and XSLT library based on the following signature:
  xmlDetectedError(user_err_ctxt, error_code, file, line, unformated_msg,
                   ...);
  where 
    user_err_ctxt: is an user provided error context 
    error_code: is one uniquely allocated error number through both
                libxml2/libxslt and where xmlsec or other libs could
                allocate their own parts
    file, line: being attempts when possible to provide some context,
                not always possible like in memory allocation errors
    msg:        the unformated error message, dependant on error_code
                but not conditionalized by I18N (localization should be
                done at the app level based on error_code)
    ...:        the extra arguments passed, depends on error_code

By doing this, you provide necessary functionality
for apps who care about that and in the same time,
you have full backward API/ABI compatibility.
  right it's an API extension.
  This would require also adding:
    - registering function both globally and for parsing/validation/xslt
      contexts. This means global or thread specific new variables.
    - adding error codes for everything in xmlerror.h

All the nightmares with managing context in mutltithreading
environment is left to application (it's relatievly easy in each
particular case but very hard to write a good "general" solution).

   right

Also, the change could be done in piece (i.e. no scary big checkins).

   Ideally by using top macros inherited from xmlerror.h, it's probably
possible to minimize most of the code changes. Unfortunately C doesn't
have support for macros with varargs ...

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]