You are here

public static function MigrateItemsXML::parseLibXMLError in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/xml.inc \MigrateItemsXML::parseLibXMLError()

Parses a LibXMLError to a error message string.

Parameters

LibXMLError $error: Error thrown by the XML

Return value

string Error message

3 calls to MigrateItemsXML::parseLibXMLError()
MigrateItemsXML::xml in plugins/sources/xml.inc
Load and return the xml from currentUrl.
MigrateListXML::getIdList in plugins/sources/xml.inc
Load the XML at the given URL, and return an array of the IDs found within it.
MigrateXMLReader::next in plugins/sources/xml.inc
Implementation of Iterator::next().

File

plugins/sources/xml.inc, line 585
Support for migration from XML sources.

Class

MigrateItemsXML
Implementation of MigrateItems, for providing a list of IDs and for retrieving a parsed XML document given an ID from this list.

Code

public static function parseLibXMLError(LibXMLError $error) {
  $error_code_name = 'Unknown Error';
  switch ($error->level) {
    case LIBXML_ERR_WARNING:
      $error_code_name = t('Warning');
      break;
    case LIBXML_ERR_ERROR:
      $error_code_name = t('Error');
      break;
    case LIBXML_ERR_FATAL:
      $error_code_name = t('Fatal Error');
      break;
  }
  return t("!libxmlerrorcodename !libxmlerrorcode: !libxmlerrormessage\n" . "Line: !libxmlerrorline\n" . "Column: !libxmlerrorcolumn\n" . "File: !libxmlerrorfile", array(
    '!libxmlerrorcodename' => $error_code_name,
    '!libxmlerrorcode' => $error->code,
    '!libxmlerrormessage' => trim($error->message),
    '!libxmlerrorline' => $error->line,
    '!libxmlerrorcolumn' => $error->column,
    '!libxmlerrorfile' => $error->file ? $error->file : NULL,
  ));
}