mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
parent
e7d52d3f91
commit
941df19e88
@ -39,7 +39,7 @@ class YamlReader implements Reader
|
||||
// Normalise messages
|
||||
return $this->normaliseMessages($yaml[$locale]);
|
||||
} catch (ParseException $exception) {
|
||||
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $path), 0, $exception);
|
||||
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s". Message: %s', $path, $exception->getMessage()), 0, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\i18n\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\i18n\Messages\YamlReader;
|
||||
use Symfony\Component\Translation\Exception\InvalidResourceException;
|
||||
|
||||
class YamlReaderTest extends SapphireTest
|
||||
{
|
||||
@ -38,4 +39,15 @@ class YamlReaderTest extends SapphireTest
|
||||
];
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
|
||||
|
||||
public function testThrowsMeaningfulExceptionWhenYmlIsCorrupted()
|
||||
{
|
||||
$path = __DIR__ . '/i18nTest/_fakewebroot/i18ntestmodule/lang/en_corrupt.yml';
|
||||
$this->expectException(InvalidResourceException::class);
|
||||
$regex_path = str_replace('.', '\.', $path);
|
||||
$this->expectExceptionMessageRegExp('@^Error parsing YAML, invalid file "' . $regex_path . '"\. Message: ([\w ].*) line 5 @');
|
||||
$reader = new YamlReader();
|
||||
$reader->read('en', $path);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
en:
|
||||
NONAMESPACE: Include Entity without Namespace
|
||||
Invalid: Foo
|
||||
About: 'About us'
|
||||
- Invalid # this should throw "A colon cannot be used in an unquoted mapping value at line 5"
|
Loading…
Reference in New Issue
Block a user