diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index dad166d7c4..7efa151140 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -125,7 +125,7 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - $this->message .= sprintf(' in %s', json_encode($this->parsedFile)); + $this->message .= sprintf(' in "%s"', $this->parsedFile); } if ($this->parsedLine >= 0) { diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php new file mode 100644 index 0000000000..7d0dea837c --- /dev/null +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class ParseExceptionTest extends \PHPUnit_Framework_TestCase +{ + public function testGetMessage() + { + $exception = new ParseException( + 'Error message', 42, 'foo: bar', '/var/www/app/config.yml' + ); + + $this->assertEquals( + 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")', + $exception->getMessage() + ); + } +}