Skip to content

Unclear exception in XmlFileLoader #61493

@samdark

Description

@samdark

Symfony version(s) affected

any

Description

https://github.com/symfony/validator/blob/7.3/Mapping/Loader/XmlFileLoader.php

protected function parseFile(string $path): \SimpleXMLElement
  {
      try {
          $dom = XmlUtils::loadFile($path, __DIR__.'/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd');
      } catch (\Exception $e) {
          throw new MappingException($e->getMessage(), $e->getCode(), $e);
      }

      return simplexml_import_dom($dom);
  }

MappingException doesn't include $path so when the exception occurs it's impossible to tell which file failed:

Uncaught PHP Exception Symfony\Component\Validator\Exception\MappingException: "[ERROR 3069] Internal error: xmlSchemaPValAttrNodeValue, the given type is not a built-in type. (in n/a - line 0, column 0) [ERROR 3069] Internal error: xmlSchemaParse, An internal error occurred. (in n/a - line 0, column 0)" at XmlFileLoader.php line 182

How to reproduce

Cause MappingException.

Possible Solution

I propose to add file name to the message.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions