Skip to content

Commit

Permalink
Improved exception message for a non-unique language code (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs authored Oct 11, 2023
1 parent 22f4600 commit 0ef85fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib/Repository/LanguageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public function createLanguage(LanguageCreateStruct $languageCreateStruct): Lang

try {
if ($this->loadLanguage($languageCreateStruct->languageCode) !== null) {
throw new InvalidArgumentException('languageCreateStruct', 'language with the specified language code already exists');
throw new InvalidArgumentException(
'languageCreateStruct',
sprintf('language with the "%s" language code already exists', $languageCreateStruct->languageCode)
);
}
} catch (APINotFoundException $e) {
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/Core/Repository/LanguageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testCreateLanguageSetsExpectedProperties($language)
public function testCreateLanguageThrowsInvalidArgumentException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the specified language code already exists');
$this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the "nor-NO" language code already exists');

$repository = $this->getRepository();

Expand Down

0 comments on commit 0ef85fa

Please sign in to comment.