You are here

protected function FeedsExXml::getErrors in Feeds extensible parsers 7

Same name and namespace in other branches
  1. 7.2 src/FeedsExXml.inc \FeedsExXml::getErrors()

Returns the errors after parsing.

Return value

array A structured array array with keys:

  • message: The error message.
  • variables: The variables for the message.
  • severity: The severity of the message.

Overrides FeedsExBase::getErrors

See also

watchdog()

File

src/FeedsExXml.inc, line 309
Contains FeedsExXml.

Class

FeedsExXml
Parses XML documents with XPath.

Code

protected function getErrors() {
  $return = array();
  foreach (libxml_get_errors() as $error) {

    // Translate error values.
    switch ($error->level) {
      case LIBXML_ERR_FATAL:
        $severity = WATCHDOG_ERROR;
        break;
      case LIBXML_ERR_ERROR:
        $severity = WATCHDOG_WARNING;
        break;
      default:
        $severity = WATCHDOG_NOTICE;
        break;
    }
    $return[] = array(
      'message' => '%error on line %num. Error code: %code',
      'variables' => array(
        '%error' => trim($error->message),
        '%num' => $error->line,
        '%code' => $error->code,
      ),
      'severity' => $severity,
    );
  }
  return $return;
}