[PROPOSAL] Changes to XML_Parser_Error
| From: | (Mikhail Zabaluev) | Date: | Mon, 23 Oct 2000 05:08:48 +0000 |
| Subject: | [PROPOSAL] Changes to XML_Parser_Error | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-417@lists.php.net to get a copy of this message | ||
Hello, PEAR-growers.
I suggest an improvement to the XML_Parser_Error class from XML/Parser.php
such that it contains input line number in a separate member.
Here's the code:
/**
* the XML parser error class encapsulating a line number
*/
class XML_Parser_Error extends PEAR_Error {
var $error_message_prefix = 'XML_Parser: ';
var $line_number;
// {{{ constructor
/**
* create an error message provided with line number
*
* @param resource $parser an XML parser resource
* @param string $message message string, overrides an expat message
* when set
* @see PEAR_Error
*/
function XML_Parser_Error($parser,
$message = false,
$code = 0,
$mode = null,
$options = null,
$debuginfo = null)
{
$this->line_number = xml_get_current_line_number($parser);
if ($message === false) {
$message = xml_error_string(xml_get_error_code($parser));
}
$this->PEAR_Error($message, $code, $mode, $options, $debuginfo);
}
// }}}
// {{{ getMessage()
/**
* @see PEAR_Error::getMessage()
*/
function getMessage()
{
return sprintf("%s at XML input line %d",
parent:getMessage(),
$this->line_number);
}
// }}}
}
--
Stay tuned,
MhZ mailto:mookid@sigent.ru
-----------
Lady Nancy Astor:
"Winston, if you were my husband, I'd put poison in your coffee."
Winston Churchill:
"Nancy, if you were my wife, I'd drink it."