-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
InvalidResourceException file name #14762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added filen ame to the InvalidResourceException,
@@ -148,7 +148,7 @@ private function parseFile($file) | |||
$source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source); | |||
|
|||
if (!@$dom->schemaValidateSource($source)) { | |||
throw new InvalidResourceException(implode("\n", $this->getXmlErrors($internalErrors))); | |||
throw new InvalidResourceException("File:$file\n".implode("\n", $this->getXmlErrors($internalErrors))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be more verbose and say something like The "file.xlf" is not a valid resource.
Also, our coding standard favours single quotes, and sprintf should be used to create an exception message:
throw new InvalidResourceException(sprintf('The "%s" is not a valid resource: ', $file, implode("\n", $this->getXmlErrors($internalErrors))));
Refactored InvalidResourceException message.
@@ -148,7 +148,7 @@ private function parseFile($file) | |||
$source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source); | |||
|
|||
if (!@$dom->schemaValidateSource($source)) { | |||
throw new InvalidResourceException(implode("\n", $this->getXmlErrors($internalErrors))); | |||
throw new InvalidResourceException(sprintf('The "%s" is not a valid resource: ', $file, implode("\n", $this->getXmlErrors($internalErrors)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "my_file.xml" is not a valid resource
, This sounds a bit weird. What if you format it like this?
'Invalid resource provided: "%s"; Errors: %s'
, note that you forgot the second %s
in your commit.
👍 should be merged in 2.3 |
Thank you @DancZer. |
Added filen ame to the InvalidResourceException,