xml errors (was Re: [PHP-PEAR] DB error reporting and DB/ifx.php)

[email protected] ("Tomas V.V.Cox") Wed, 28 Feb 2001 18:48:29 +0100
Newsgroups php.pear
Message-ID <[email protected]>
Chuck Hagenbuch wrote:
> 
> Quoting "Tomas V.V.Cox" <[email protected]>:
> 
> > // an especific database method
> > function getNativeError (){
> >       return '<br><b>'.ifx_error().'</b> '.ifx_errormsg();
> > }
> 
> This is a nit in the context of your message, but it's an important nit: don't
> put html in error messages. If you have to return a structured string, use xml
> so that users can transform it into whatever form they need. But I think we
> should try to have all PEAR error messages be unstructured strings or error
> codes, so that programmers using the APIs can do whatever they need to do with
> errors with a minimum of fuss.

Yes it is a great idea, IMHO perhaps a little bit complicated. My
personal system for that you comment, is always use html and map it to
text when running from console (something like br2nl() and striptags()).
Well XML, any ideas about de DTD, examples? Thinking fast, for ex:
<error>
	<user title="Warnign">the query fail</user>
	<debug title="2810">Missing table name</debug>
</error>

The full error str in a web env, could be rendered as:
<i>Warning: the query fail</i><br>
<b>Error: 2810</b> Missing table name

One problem with the XML aproach is that people should have XML or DOM
compiled in, not yet very standar (i think), and probably some loose of
performance.

Tomas V.V.Cox