Skip to content

Commit

Permalink
More error info about XML parse failures
Browse files Browse the repository at this point in the history
  • Loading branch information
donal72 committed Nov 2, 2007
1 parent dcbef19 commit d60a9e4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion mnet/xmlrpc/xmlparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,23 @@ function parse($data) {
// Parse failed
$errcode = xml_get_error_code($this->parser);
$errstring = xml_error_string($errcode);
$this->error[] = array('code' => $errcode, 'string' => $errstring);
$lineno = xml_get_current_line_number($this->parser);
if ($lineno !== false) {
$error = array('lineno' => $lineno);
$lineno--; // Line numbering starts at 1.
while ($lineno > 0) {
$data = strstr($data, "\n");
$lineno--;
}
$data .= "\n"; // In case there's only one line (no newline)
$line = substr($data, 0, strpos($data, "\n"));
$error['code'] = $errcode;
$error['string'] = $errstring;
$error['line'] = $line;
$this->error[] = $error;
} else {
$this->error[] = array('code' => $errcode, 'string' => $errstring);
}
}

if (count($this->cipher) > 0) {
Expand Down

0 comments on commit d60a9e4

Please sign in to comment.