You are here

public static function XmlTrait::parseLibXmlError in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate_plus/data_parser/XmlTrait.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\XmlTrait::parseLibXmlError()
  2. 8.2 src/Plugin/migrate_plus/data_parser/XmlTrait.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\XmlTrait::parseLibXmlError()
  3. 8.3 src/Plugin/migrate_plus/data_parser/XmlTrait.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\XmlTrait::parseLibXmlError()

Parses a LibXMLError to a error message string.

Parameters

\LibXMLError $error: Error thrown by the XML.

Return value

string Error message

2 calls to XmlTrait::parseLibXmlError()
SimpleXml::openSourceUrl in src/Plugin/migrate_plus/data_parser/SimpleXml.php
Opens the specified URL.
Xml::getSimpleXml in src/Plugin/migrate_plus/data_parser/Xml.php
Builds a \SimpleXmlElement rooted at the iterator's current location.

File

src/Plugin/migrate_plus/data_parser/XmlTrait.php, line 33

Class

XmlTrait
Common functionality for XML data parsers.

Namespace

Drupal\migrate_plus\Plugin\migrate_plus\data_parser

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\nLine: @libxmlerrorline\nColumn: @libxmlerrorcolumn\nFile: @libxmlerrorfile", [
    '@libxmlerrorcodename' => $error_code_name,
    '@libxmlerrorcode' => $error->code,
    '@libxmlerrormessage' => trim($error->message),
    '@libxmlerrorline' => $error->line,
    '@libxmlerrorcolumn' => $error->column,
    '@libxmlerrorfile' => $error->file ? $error->file : NULL,
  ]);
}